mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
8
internal/cache/account.go
vendored
8
internal/cache/account.go
vendored
@@ -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
|
||||
|
8
internal/cache/status.go
vendored
8
internal/cache/status.go
vendored
@@ -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
|
||||
|
@@ -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) {
|
||||
|
@@ -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) {
|
||||
|
@@ -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")
|
||||
}
|
||||
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
})
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user