From 5cf263a86f954a38cbfafb6b0857bf591f82a811 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 27 Mar 2022 16:55:37 +0200 Subject: [PATCH] feat: upgrade golangci-lint to 1.45.2 --- .drone.yml | 4 +-- .golangci.yml | 10 +++++- pkg/config/config.go | 2 +- pkg/db/db.go | 2 +- pkg/files/files.go | 5 +-- pkg/integrations/integrations.go | 5 +-- pkg/migration/20200621214452.go | 6 ++-- pkg/models/export.go | 2 +- pkg/models/list_duplicate.go | 2 +- pkg/models/tasks.go | 2 +- pkg/models/user_list.go | 2 +- pkg/modules/auth/openid/openid.go | 6 ++-- pkg/modules/dump/dump.go | 14 ++++---- pkg/modules/dump/restore.go | 32 +++++++++---------- pkg/modules/migration/vikunja-file/vikunja.go | 26 +++++++-------- pkg/routes/api/v1/user_totp.go | 7 ++-- pkg/routes/api/v1/user_update_email.go | 4 ++- pkg/routes/routes.go | 2 +- pkg/utils/umask_unix.go | 1 + pkg/utils/write_to_zip.go | 2 +- 20 files changed, 77 insertions(+), 59 deletions(-) diff --git a/.drone.yml b/.drone.yml index 05cafa6f36..e1f6fa3138 100644 --- a/.drone.yml +++ b/.drone.yml @@ -138,7 +138,7 @@ steps: GOPROXY: 'https://goproxy.kolaente.de' depends_on: [ build ] commands: - - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0 + - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2 - ./mage-static check:all when: event: [ push, tag, pull_request ] @@ -874,6 +874,6 @@ steps: - failure --- kind: signature -hmac: de40fb1378ab65f47d8c518f503eefede9284dd5634e033dd50abf0a6ec33645 +hmac: 1c4c211e66e4b6eddd2a1c1bad31e5c960d4f67d6033f4d5c4de7896dfae6c30 ... diff --git a/.golangci.yml b/.golangci.yml index 967ba5d1a6..2b53a2f6e8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,10 +13,11 @@ linters: - goheader - gofmt - goimports - - golint + - revive - misspell disable: - scopelint # Obsolete, using exportloopref instead + - durationcheck presets: - bugs - unused @@ -35,6 +36,7 @@ issues: linters: - gocyclo - deadcode + - errorlint - path: pkg/integrations/* linters: - gocyclo @@ -80,3 +82,9 @@ issues: - text: "Missed string" linters: - goheader + - path: pkg/.*/error.go + linters: + - errorlint + - path: pkg/models/favorites\.go + linters: + - nilerr diff --git a/pkg/config/config.go b/pkg/config/config.go index 0c139249b2..f5eee2deb0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -46,7 +46,7 @@ const ( ServiceEnableCaldav Key = `service.enablecaldav` ServiceRootpath Key = `service.rootpath` ServiceMaxItemsPerPage Key = `service.maxitemsperpage` - // Deprecated. Use metrics.enabled + // Deprecated: Use metrics.enabled ServiceEnableMetrics Key = `service.enablemetrics` ServiceMotd Key = `service.motd` ServiceEnableLinkSharing Key = `service.enablelinksharing` diff --git a/pkg/db/db.go b/pkg/db/db.go index 728cd7cf7c..617b8b7b28 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -186,7 +186,7 @@ func initSqliteEngine() (engine *xorm.Engine, err error) { } file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0) if err != nil { - return nil, fmt.Errorf("could not open database file [uid=%d, gid=%d]: %s", os.Getuid(), os.Getgid(), err) + return nil, fmt.Errorf("could not open database file [uid=%d, gid=%d]: %w", os.Getuid(), os.Getgid(), err) } _ = file.Close() // We directly close the file because we only want to check if it is writable. It will be reopened lazily later by xorm. diff --git a/pkg/files/files.go b/pkg/files/files.go index 08beb97716..cea65668cb 100644 --- a/pkg/files/files.go +++ b/pkg/files/files.go @@ -17,6 +17,7 @@ package files import ( + "errors" "io" "os" "strconv" @@ -136,9 +137,9 @@ func (f *File) Delete() (err error) { err = afs.Remove(f.getFileName()) if err != nil { - if e, is := err.(*os.PathError); is { + if errors.Is(err, &os.PathError{}) { // Don't fail when removing the file failed - log.Errorf("Error deleting file %d: %s", e.Error()) + log.Errorf("Error deleting file %d: %w", err) return s.Commit() } diff --git a/pkg/integrations/integrations.go b/pkg/integrations/integrations.go index 77f3a3ac27..84cb9eea1d 100644 --- a/pkg/integrations/integrations.go +++ b/pkg/integrations/integrations.go @@ -17,6 +17,7 @@ package integrations import ( + "errors" "net/http" "net/http/httptest" "net/url" @@ -174,8 +175,8 @@ func assertHandlerErrorCode(t *testing.T, err error, expectedErrorCode int) { t.Error("Error is nil") t.FailNow() } - httperr, ok := err.(*echo.HTTPError) - if !ok { + var httperr *echo.HTTPError + if !errors.As(err, &httperr) { t.Error("Error is not *echo.HTTPError") t.FailNow() } diff --git a/pkg/migration/20200621214452.go b/pkg/migration/20200621214452.go index 968649acb3..33a9dc47e9 100644 --- a/pkg/migration/20200621214452.go +++ b/pkg/migration/20200621214452.go @@ -683,17 +683,17 @@ create unique index UQE_users_namespace_id sess := tx.NewSession() if err := sess.Begin(); err != nil { - return fmt.Errorf("unable to open session: %s", err) + return fmt.Errorf("unable to open session: %w", err) } for _, s := range sql { _, err := sess.Exec(s) if err != nil { _ = sess.Rollback() - return fmt.Errorf("error executing update data for table %s, column %s: %s", table, column, err) + return fmt.Errorf("error executing update data for table %s, column %s: %w", table, column, err) } } if err := sess.Commit(); err != nil { - return fmt.Errorf("error committing data change: %s", err) + return fmt.Errorf("error committing data change: %w", err) } return nil } diff --git a/pkg/models/export.go b/pkg/models/export.go index 472b68ef79..87c6dde657 100644 --- a/pkg/models/export.go +++ b/pkg/models/export.go @@ -49,7 +49,7 @@ func ExportUserData(s *xorm.Session, u *user.User) (err error) { // Open zip dumpFile, err := os.Create(tmpFilename) if err != nil { - return fmt.Errorf("error opening dump file: %s", err) + return fmt.Errorf("error opening dump file: %w", err) } defer dumpFile.Close() diff --git a/pkg/models/list_duplicate.go b/pkg/models/list_duplicate.go index 793dc10b18..33cf7e2cf4 100644 --- a/pkg/models/list_duplicate.go +++ b/pkg/models/list_duplicate.go @@ -216,7 +216,7 @@ func duplicateTasks(s *xorm.Session, doer web.Auth, ld *ListDuplicate, bucketMap // It is used to map old task items to new ones. taskMap := make(map[int64]int64) // Create + update all tasks (includes reminders) - oldTaskIDs := make([]int64, len(tasks)) + oldTaskIDs := make([]int64, 0, len(tasks)) for _, t := range tasks { oldID := t.ID t.ID = 0 diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index f32c7ecdc9..b7a139a926 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -402,7 +402,7 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO return nil, 0, 0, err } - userListIDs := make([]int64, len(userLists)) + userListIDs := make([]int64, 0, len(userLists)) for _, l := range userLists { userListIDs = append(userListIDs, l.ID) } diff --git a/pkg/models/user_list.go b/pkg/models/user_list.go index ae3550952e..bbb5798096 100644 --- a/pkg/models/user_list.go +++ b/pkg/models/user_list.go @@ -91,7 +91,7 @@ func ListUsersFromList(s *xorm.Session, l *List, search string) (users []*user.U uidmap[u.TeamNamespaceUserID] = true } - uids := make([]int64, len(uidmap)) + uids := make([]int64, 0, len(uidmap)) for id := range uidmap { uids = append(uids, id) } diff --git a/pkg/modules/auth/openid/openid.go b/pkg/modules/auth/openid/openid.go index 4cc6e9f55b..c282bea8f6 100644 --- a/pkg/modules/auth/openid/openid.go +++ b/pkg/modules/auth/openid/openid.go @@ -19,6 +19,7 @@ package openid import ( "context" "encoding/json" + "errors" "math/rand" "net/http" "time" @@ -104,12 +105,13 @@ func HandleCallback(c echo.Context) error { // Parse the access & ID token oauth2Token, err := provider.Oauth2Config.Exchange(context.Background(), cb.Code) if err != nil { - if rerr, is := err.(*oauth2.RetrieveError); is { + var rerr *oauth2.RetrieveError + if errors.As(err, &rerr) { log.Error(err) details := make(map[string]interface{}) if err := json.Unmarshal(rerr.Body, &details); err != nil { - log.Errorf("Error unmarshaling token for provider %s: %v", provider.Name, err) + log.Errorf("Error unmarshalling token for provider %s: %v", provider.Name, err) return handler.HandleHTTPError(err, c) } diff --git a/pkg/modules/dump/dump.go b/pkg/modules/dump/dump.go index 3811ffc580..2e25e9b4e8 100644 --- a/pkg/modules/dump/dump.go +++ b/pkg/modules/dump/dump.go @@ -35,7 +35,7 @@ import ( func Dump(filename string) error { dumpFile, err := os.Create(filename) if err != nil { - return fmt.Errorf("error opening dump file: %s", err) + return fmt.Errorf("error opening dump file: %w", err) } defer dumpFile.Close() @@ -47,7 +47,7 @@ func Dump(filename string) error { if viper.ConfigFileUsed() != "" { err = writeFileToZip(viper.ConfigFileUsed(), dumpWriter) if err != nil { - return fmt.Errorf("error saving config file: %s", err) + return fmt.Errorf("error saving config file: %w", err) } } else { log.Warning("No config file found, not including one in the dump. This usually happens when environment variables are used for configuration.") @@ -64,7 +64,7 @@ func Dump(filename string) error { if dotEnv != "" { err = utils.WriteBytesToZip(".env", []byte(dotEnv), dumpWriter) if err != nil { - return fmt.Errorf("error saving env file: %s", err) + return fmt.Errorf("error saving env file: %w", err) } log.Info("Dumped .env file") } @@ -73,7 +73,7 @@ func Dump(filename string) error { log.Info("Start dumping version file...") err = utils.WriteBytesToZip("VERSION", []byte(version.Version), dumpWriter) if err != nil { - return fmt.Errorf("error saving version: %s", err) + return fmt.Errorf("error saving version: %w", err) } log.Info("Dumped version") @@ -81,12 +81,12 @@ func Dump(filename string) error { log.Info("Start dumping database...") data, err := db.Dump() if err != nil { - return fmt.Errorf("error saving database data: %s", err) + return fmt.Errorf("error saving database data: %w", err) } for t, d := range data { err = utils.WriteBytesToZip("database/"+t+".json", d, dumpWriter) if err != nil { - return fmt.Errorf("error writing database table %s: %s", t, err) + return fmt.Errorf("error writing database table %s: %w", t, err) } } log.Info("Dumped database") @@ -95,7 +95,7 @@ func Dump(filename string) error { log.Info("Start dumping files...") allFiles, err := files.Dump() if err != nil { - return fmt.Errorf("error saving file: %s", err) + return fmt.Errorf("error saving file: %w", err) } err = utils.WriteFilesToZip(allFiles, dumpWriter) diff --git a/pkg/modules/dump/restore.go b/pkg/modules/dump/restore.go index 846ab1b6ee..47ce9b51ef 100644 --- a/pkg/modules/dump/restore.go +++ b/pkg/modules/dump/restore.go @@ -44,7 +44,7 @@ func Restore(filename string) error { r, err := zip.OpenReader(filename) if err != nil { - return fmt.Errorf("could not open zip file: %s", err) + return fmt.Errorf("could not open zip file: %w", err) } log.Warning("Restoring a dump will wipe your current installation!") @@ -52,7 +52,7 @@ func Restore(filename string) error { cr := bufio.NewReader(os.Stdin) text, err := cr.ReadString('\n') if err != nil { - return fmt.Errorf("could not read confirmation message: %s", err) + return fmt.Errorf("could not read confirmation message: %w", err) } if text != "Yes, I understand\n" { return fmt.Errorf("invalid confirmation message") @@ -99,7 +99,7 @@ func Restore(filename string) error { // Restore the db // Start by wiping everything if err := db.WipeEverything(); err != nil { - return fmt.Errorf("could not wipe database: %s", err) + return fmt.Errorf("could not wipe database: %w", err) } log.Info("Wiped database.") @@ -108,18 +108,18 @@ func Restore(filename string) error { migrations := dbfiles["migration"] rc, err := migrations.Open() if err != nil { - return fmt.Errorf("could not open migrations: %s", err) + return fmt.Errorf("could not open migrations: %w", err) } defer rc.Close() var buf bytes.Buffer if _, err := buf.ReadFrom(rc); err != nil { - return fmt.Errorf("could not read migrations: %s", err) + return fmt.Errorf("could not read migrations: %w", err) } ms := []*xormigrate.Migration{} if err := json.Unmarshal(buf.Bytes(), &ms); err != nil { - return fmt.Errorf("could not read migrations: %s", err) + return fmt.Errorf("could not read migrations: %w", err) } sort.Slice(ms, func(i, j int) bool { return ms[i].ID > ms[j].ID @@ -127,17 +127,17 @@ func Restore(filename string) error { lastMigration := ms[len(ms)-1] if err := migration.MigrateTo(lastMigration.ID, nil); err != nil { - return fmt.Errorf("could not create db structure: %s", err) + return fmt.Errorf("could not create db structure: %w", err) } // Restore all db data for table, d := range dbfiles { content, err := unmarshalFileToJSON(d) if err != nil { - return fmt.Errorf("could not read table %s: %s", table, err) + return fmt.Errorf("could not read table %s: %w", table, err) } if err := db.Restore(table, content); err != nil { - return fmt.Errorf("could not restore table data for table %s: %s", table, err) + return fmt.Errorf("could not restore table data for table %s: %w", table, err) } log.Infof("Restored table %s", table) } @@ -151,18 +151,18 @@ func Restore(filename string) error { for i, file := range filesFiles { id, err := strconv.ParseInt(i, 10, 64) if err != nil { - return fmt.Errorf("could not parse file id %s: %s", i, err) + return fmt.Errorf("could not parse file id %s: %w", i, err) } f := &files.File{ID: id} fc, err := file.Open() if err != nil { - return fmt.Errorf("could not open file %s: %s", i, err) + return fmt.Errorf("could not open file %s: %w", i, err) } if err := f.Save(fc); err != nil { - return fmt.Errorf("could not save file: %s", err) + return fmt.Errorf("could not save file: %w", err) } _ = fc.Close() @@ -205,7 +205,7 @@ func restoreConfig(configFile, dotEnvFile *zip.File) error { outFile, err := os.OpenFile(configFile.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, configFile.Mode()) if err != nil { - return fmt.Errorf("could not open config file for writing: %s", err) + return fmt.Errorf("could not open config file for writing: %w", err) } cfgr, err := configFile.Open() @@ -216,7 +216,7 @@ func restoreConfig(configFile, dotEnvFile *zip.File) error { // #nosec - We eliminated the potential decompression bomb by erroring out above if the file is larger than a threshold. _, err = io.Copy(outFile, cfgr) if err != nil { - return fmt.Errorf("could not create config file: %s", err) + return fmt.Errorf("could not create config file: %w", err) } _ = cfgr.Close() @@ -225,7 +225,7 @@ func restoreConfig(configFile, dotEnvFile *zip.File) error { log.Infof("The config file has been restored to '%s'.", configFile.Name) log.Infof("You can now make changes to it, hit enter when you're done.") if _, err := bufio.NewReader(os.Stdin).ReadString('\n'); err != nil { - return fmt.Errorf("could not read from stdin: %s", err) + return fmt.Errorf("could not read from stdin: %w", err) } return nil @@ -249,7 +249,7 @@ func restoreConfig(configFile, dotEnvFile *zip.File) error { log.Warning("Make sure your current config matches the following env variables, confirm by pressing enter when done.") log.Warning("If your config does not match, you'll have to make the changes and restart the restoring process afterwards.") if _, err := bufio.NewReader(os.Stdin).ReadString('\n'); err != nil { - return fmt.Errorf("could not read from stdin: %s", err) + return fmt.Errorf("could not read from stdin: %w", err) } } diff --git a/pkg/modules/migration/vikunja-file/vikunja.go b/pkg/modules/migration/vikunja-file/vikunja.go index 7005744f40..5fe953c353 100644 --- a/pkg/modules/migration/vikunja-file/vikunja.go +++ b/pkg/modules/migration/vikunja-file/vikunja.go @@ -64,7 +64,7 @@ func (v *FileMigrator) Name() string { func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) error { r, err := zip.NewReader(file, size) if err != nil { - return fmt.Errorf("could not open import file: %s", err) + return fmt.Errorf("could not open import file: %w", err) } log.Debugf(logPrefix+"Importing a zip file containing %d files", len(r.File)) @@ -77,7 +77,7 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er fname := strings.ReplaceAll(f.Name, "files/", "") id, err := strconv.ParseInt(fname, 10, 64) if err != nil { - return fmt.Errorf("could not convert file id: %s", err) + return fmt.Errorf("could not convert file id: %w", err) } storedFiles[id] = f log.Debugf(logPrefix + "Found a blob file") @@ -104,18 +104,18 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er // Import the bulk of Vikunja data df, err := dataFile.Open() if err != nil { - return fmt.Errorf("could not open data file: %s", err) + return fmt.Errorf("could not open data file: %w", err) } defer df.Close() var bufData bytes.Buffer if _, err := bufData.ReadFrom(df); err != nil { - return fmt.Errorf("could not read data file: %s", err) + return fmt.Errorf("could not read data file: %w", err) } namespaces := []*models.NamespaceWithListsAndTasks{} if err := json.Unmarshal(bufData.Bytes(), &namespaces); err != nil { - return fmt.Errorf("could not read data: %s", err) + return fmt.Errorf("could not read data: %w", err) } for _, n := range namespaces { @@ -123,11 +123,11 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er if b, exists := storedFiles[l.BackgroundFileID]; exists { bf, err := b.Open() if err != nil { - return fmt.Errorf("could not open list background file %d for reading: %s", l.BackgroundFileID, err) + return fmt.Errorf("could not open list background file %d for reading: %w", l.BackgroundFileID, err) } var buf bytes.Buffer if _, err := buf.ReadFrom(bf); err != nil { - return fmt.Errorf("could not read list background file %d: %s", l.BackgroundFileID, err) + return fmt.Errorf("could not read list background file %d: %w", l.BackgroundFileID, err) } l.BackgroundInformation = &buf @@ -143,11 +143,11 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er for _, attachment := range t.Attachments { af, err := storedFiles[attachment.File.ID].Open() if err != nil { - return fmt.Errorf("could not open attachment %d for reading: %s", attachment.ID, err) + return fmt.Errorf("could not open attachment %d for reading: %w", attachment.ID, err) } var buf bytes.Buffer if _, err := buf.ReadFrom(af); err != nil { - return fmt.Errorf("could not read attachment %d: %s", attachment.ID, err) + return fmt.Errorf("could not read attachment %d: %w", attachment.ID, err) } attachment.ID = 0 @@ -160,7 +160,7 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er err = migration.InsertFromStructure(namespaces, user) if err != nil { - return fmt.Errorf("could not insert data: %s", err) + return fmt.Errorf("could not insert data: %w", err) } if filterFile == nil { @@ -172,18 +172,18 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er // Import filters ff, err := filterFile.Open() if err != nil { - return fmt.Errorf("could not open filters file: %s", err) + return fmt.Errorf("could not open filters file: %w", err) } defer ff.Close() var bufFilter bytes.Buffer if _, err := bufFilter.ReadFrom(ff); err != nil { - return fmt.Errorf("could not read filters file: %s", err) + return fmt.Errorf("could not read filters file: %w", err) } filters := []*models.SavedFilter{} if err := json.Unmarshal(bufFilter.Bytes(), &filters); err != nil { - return fmt.Errorf("could not read filter data: %s", err) + return fmt.Errorf("could not read filter data: %w", err) } log.Debugf(logPrefix+"Importing %d saved filters", len(filters)) diff --git a/pkg/routes/api/v1/user_totp.go b/pkg/routes/api/v1/user_totp.go index 7996d1f957..7a1e286abe 100644 --- a/pkg/routes/api/v1/user_totp.go +++ b/pkg/routes/api/v1/user_totp.go @@ -18,6 +18,7 @@ package v1 import ( "bytes" + "errors" "fmt" "image/jpeg" "net/http" @@ -91,7 +92,8 @@ func UserTOTPEnable(c echo.Context) error { } if err := c.Bind(passcode); err != nil { log.Debugf("Invalid model error. Internal error was: %s", err.Error()) - if he, is := err.(*echo.HTTPError); is { + var he *echo.HTTPError + if errors.As(err, &he) { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) } return echo.NewHTTPError(http.StatusBadRequest, "Invalid model provided.") @@ -131,7 +133,8 @@ func UserTOTPDisable(c echo.Context) error { login := &user.Login{} if err := c.Bind(login); err != nil { log.Debugf("Invalid model error. Internal error was: %s", err.Error()) - if he, is := err.(*echo.HTTPError); is { + var he *echo.HTTPError + if errors.As(err, &he) { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) } return echo.NewHTTPError(http.StatusBadRequest, "Invalid model provided.") diff --git a/pkg/routes/api/v1/user_update_email.go b/pkg/routes/api/v1/user_update_email.go index 52b4b5eea8..c14b1a40d2 100644 --- a/pkg/routes/api/v1/user_update_email.go +++ b/pkg/routes/api/v1/user_update_email.go @@ -17,6 +17,7 @@ package v1 import ( + "errors" "fmt" "net/http" @@ -47,7 +48,8 @@ func UpdateUserEmail(c echo.Context) (err error) { var emailUpdate = &user.EmailUpdate{} if err := c.Bind(emailUpdate); err != nil { log.Debugf("Invalid model error. Internal error was: %s", err.Error()) - if he, is := err.(*echo.HTTPError); is { + var he *echo.HTTPError + if errors.As(err, &he) { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid model provided. Error was: %s", he.Message)) } return echo.NewHTTPError(http.StatusBadRequest, "Invalid model provided.") diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index b37387c5b7..f0d3c06b1e 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -156,7 +156,7 @@ func NewEcho() *echo.Echo { e.HTTPErrorHandler = func(err error, c echo.Context) { // Only capture errors not already handled by echo - if _, ok := err.(*echo.HTTPError); !ok { + if errors.Is(err, &echo.HTTPError{}) { hub := sentryecho.GetHubFromContext(c) if hub != nil { hub.WithScope(func(scope *sentry.Scope) { diff --git a/pkg/utils/umask_unix.go b/pkg/utils/umask_unix.go index d43c8a6de0..637222c3f9 100644 --- a/pkg/utils/umask_unix.go +++ b/pkg/utils/umask_unix.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public Licensee // along with this program. If not, see . +//go:build !windows // +build !windows package utils diff --git a/pkg/utils/write_to_zip.go b/pkg/utils/write_to_zip.go index d6771d0ed1..b6185887d2 100644 --- a/pkg/utils/write_to_zip.go +++ b/pkg/utils/write_to_zip.go @@ -54,7 +54,7 @@ func WriteFilesToZip(files map[int64]io.ReadCloser, wr *zip.Writer) (err error) } _, err = io.Copy(w, file) if err != nil { - return fmt.Errorf("error writing file %d: %s", fid, err) + return fmt.Errorf("error writing file %d: %w", fid, err) } _ = file.Close() }