summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-04-02 15:40:09 +0200
committerLibravatar GitHub <noreply@github.com>2022-04-02 15:40:09 +0200
commit03d7c75ebf1b81b12ec21f95eef1c07b265ff939 (patch)
tree511724f53946563a3b7ba1307d25f5bda98ac3a8 /internal
parent[documentation] Add third-party packaging to documentation (#443) (diff)
downloadgotosocial-03d7c75ebf1b81b12ec21f95eef1c07b265ff939.tar.xz
[chore] Update Go version to 1.18 (#444)
* linting with new golangci-lint version * update go to 1.18 * bump versions in drone.yml * use new runtime/debug package for version info * remove Commit build flag from goreleaser * remove mock commit + version from build script * go fmt * add dummy version env flag to test container * install git in golang container for testing * only set versionString if Version is defined
Diffstat (limited to 'internal')
-rw-r--r--internal/cache/account.go8
-rw-r--r--internal/cache/status.go8
-rw-r--r--internal/db/bundb/mention.go8
-rw-r--r--internal/db/bundb/notification.go8
-rw-r--r--internal/media/manager.go3
-rw-r--r--internal/processing/fromcommon.go7
-rw-r--r--internal/processing/streaming/streamdelete.go7
-rw-r--r--internal/validate/structvalidation.go7
8 files changed, 44 insertions, 12 deletions
diff --git a/internal/cache/account.go b/internal/cache/account.go
index 98f1684a4..02ec71503 100644
--- a/internal/cache/account.go
+++ b/internal/cache/account.go
@@ -91,7 +91,13 @@ func (c *AccountCache) getByID(id string) (*gtsmodel.Account, bool) {
if !ok {
return nil, false
}
- return copyAccount(v.(*gtsmodel.Account)), true
+
+ a, ok := v.(*gtsmodel.Account)
+ if !ok {
+ panic("account cache entry was not an account")
+ }
+
+ return copyAccount(a), true
}
// Put places a account in the cache, ensuring that the object place is a copy for thread-safety
diff --git a/internal/cache/status.go b/internal/cache/status.go
index 1e92c9c63..9a698c608 100644
--- a/internal/cache/status.go
+++ b/internal/cache/status.go
@@ -91,7 +91,13 @@ func (c *StatusCache) getByID(id string) (*gtsmodel.Status, bool) {
if !ok {
return nil, false
}
- return copyStatus(v.(*gtsmodel.Status)), true
+
+ s, ok := v.(*gtsmodel.Status)
+ if !ok {
+ panic("status cache entry was not a status")
+ }
+
+ return copyStatus(s), true
}
// Put places a status in the cache, ensuring that the object place is a copy for thread-safety
diff --git a/internal/db/bundb/mention.go b/internal/db/bundb/mention.go
index a93a5cef6..1c1c25c4b 100644
--- a/internal/db/bundb/mention.go
+++ b/internal/db/bundb/mention.go
@@ -46,7 +46,13 @@ func (m *mentionDB) getMentionCached(id string) (*gtsmodel.Mention, bool) {
if !ok {
return nil, false
}
- return v.(*gtsmodel.Mention), true
+
+ mention, ok := v.(*gtsmodel.Mention)
+ if !ok {
+ panic("mention cache entry was not a mention")
+ }
+
+ return mention, true
}
func (m *mentionDB) putMentionCache(mention *gtsmodel.Mention) {
diff --git a/internal/db/bundb/notification.go b/internal/db/bundb/notification.go
index e030cc623..d01bb9067 100644
--- a/internal/db/bundb/notification.go
+++ b/internal/db/bundb/notification.go
@@ -114,7 +114,13 @@ func (n *notificationDB) getNotificationCache(id string) (*gtsmodel.Notification
if !ok {
return nil, false
}
- return v.(*gtsmodel.Notification), true
+
+ notif, ok := v.(*gtsmodel.Notification)
+ if !ok {
+ panic("notification cache entry was not a notification")
+ }
+
+ return notif, true
}
func (n *notificationDB) putNotificationCache(notif *gtsmodel.Notification) {
diff --git a/internal/media/manager.go b/internal/media/manager.go
index deb7e34f7..3baab6854 100644
--- a/internal/media/manager.go
+++ b/internal/media/manager.go
@@ -274,8 +274,7 @@ func (m *manager) ActiveWorkers() int {
func (m *manager) Stop() error {
logrus.Info("stopping media manager worker pool")
- stopped := m.pool.Stop()
- if !stopped {
+ if !m.pool.Stop() {
return errors.New("could not stop media manager worker pool")
}
diff --git a/internal/processing/fromcommon.go b/internal/processing/fromcommon.go
index 8e7f20145..1b470918d 100644
--- a/internal/processing/fromcommon.go
+++ b/internal/processing/fromcommon.go
@@ -365,14 +365,13 @@ func (p *processor) timelineStatus(ctx context.Context, status *gtsmodel.Status)
// read any errors that come in from the async functions
errs := []string{}
- go func() {
+ go func(errs []string) {
for range errors {
- e := <-errors
- if e != nil {
+ if e := <-errors; e != nil {
errs = append(errs, e.Error())
}
}
- }()
+ }(errs)
// wait til all functions have returned and then close the error channel
wg.Wait()
diff --git a/internal/processing/streaming/streamdelete.go b/internal/processing/streaming/streamdelete.go
index c9c099b46..3d4efb7a7 100644
--- a/internal/processing/streaming/streamdelete.go
+++ b/internal/processing/streaming/streamdelete.go
@@ -31,7 +31,12 @@ func (p *processor) StreamDelete(statusID string) error {
// get all account IDs with open streams
accountIDs := []string{}
p.streamMap.Range(func(k interface{}, _ interface{}) bool {
- accountIDs = append(accountIDs, k.(string))
+ key, ok := k.(string)
+ if !ok {
+ panic("streamMap key was not a string (account id)")
+ }
+
+ accountIDs = append(accountIDs, key)
return true
})
diff --git a/internal/validate/structvalidation.go b/internal/validate/structvalidation.go
index d0f95c3f0..429d7a5cf 100644
--- a/internal/validate/structvalidation.go
+++ b/internal/validate/structvalidation.go
@@ -59,5 +59,10 @@ func processValidationError(err error) error {
panic(ive)
}
- return err.(validator.ValidationErrors)
+ valErr, ok := err.(validator.ValidationErrors)
+ if !ok {
+ panic("*validator.InvalidValidationError could not be coerced to validator.ValidationErrors")
+ }
+
+ return valErr
}