diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-03-21 13:39:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-21 13:39:32 +0800 |
commit | 5843038a0812cc133c1895b7410aeda7153e8708 (patch) | |
tree | 3515998242443e1a82217ee4702603819c5315c8 /internal/cmd | |
parent | 958d8b6bb4c2da66859325695b91d871e567a4fa (diff) |
workflows: enable golangci-lint (#5998)
* Create golint.yml
* Update golint.yml
* Update golint.yml
* Fix errcheck
* Fix gosimple
* Fix staticcheck
Diffstat (limited to 'internal/cmd')
-rw-r--r-- | internal/cmd/admin.go | 8 | ||||
-rw-r--r-- | internal/cmd/backup.go | 4 | ||||
-rw-r--r-- | internal/cmd/cmd.go | 4 | ||||
-rw-r--r-- | internal/cmd/import.go | 12 | ||||
-rw-r--r-- | internal/cmd/restore.go | 4 |
5 files changed, 20 insertions, 12 deletions
diff --git a/internal/cmd/admin.go b/internal/cmd/admin.go index d9275d0f..0433fb03 100644 --- a/internal/cmd/admin.go +++ b/internal/cmd/admin.go @@ -146,7 +146,9 @@ func runCreateUser(c *cli.Context) error { return errors.Wrap(err, "init configuration") } - db.SetEngine() + if err = db.SetEngine(); err != nil { + return errors.Wrap(err, "set engine") + } if err := db.CreateUser(&db.User{ Name: c.String("name"), @@ -169,7 +171,9 @@ func adminDashboardOperation(operation func() error, successMessage string) func return errors.Wrap(err, "init configuration") } - db.SetEngine() + if err = db.SetEngine(); err != nil { + return errors.Wrap(err, "set engine") + } if err := operation(); err != nil { functionName := runtime.FuncForPC(reflect.ValueOf(operation).Pointer()).Name() diff --git a/internal/cmd/backup.go b/internal/cmd/backup.go index 6448ce95..b9d9dd95 100644 --- a/internal/cmd/backup.go +++ b/internal/cmd/backup.go @@ -52,7 +52,9 @@ func runBackup(c *cli.Context) error { return errors.Wrap(err, "init configuration") } - db.SetEngine() + if err = db.SetEngine(); err != nil { + return errors.Wrap(err, "set engine") + } tmpDir := c.String("tempdir") if !com.IsExist(tmpDir) { diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 7dc2d5c5..4f172548 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -25,7 +25,7 @@ func boolFlag(name, usage string) cli.BoolFlag { } } -//nolint:deadcode +//nolint:deadcode,unused func intFlag(name string, value int, usage string) cli.IntFlag { return cli.IntFlag{ Name: name, @@ -34,7 +34,7 @@ func intFlag(name string, value int, usage string) cli.IntFlag { } } -//nolint:deadcode +//nolint:deadcode,unused func durationFlag(name string, value time.Duration, usage string) cli.DurationFlag { return cli.DurationFlag{ Name: name, diff --git a/internal/cmd/import.go b/internal/cmd/import.go index bfc83852..0bfe6c20 100644 --- a/internal/cmd/import.go +++ b/internal/cmd/import.go @@ -61,7 +61,7 @@ func runImportLocale(c *cli.Context) error { now := time.Now() - line := make([]byte, 0, 100) + var line []byte badChars := []byte(`="`) escapedQuotes := []byte(`\"`) regularQuotes := []byte(`"`) @@ -97,15 +97,15 @@ func runImportLocale(c *cli.Context) error { line = append(line[:idx+1], line[idx+2:len(line)-1]...) line = bytes.Replace(line, escapedQuotes, regularQuotes, -1) } - tw.Write(line) - tw.WriteString("\n") + _, _ = tw.Write(line) + _, _ = tw.WriteString("\n") } - sr.Close() - tw.Close() + _ = sr.Close() + _ = tw.Close() // Modification time of files from Crowdin often ahead of current, // so we need to set back to current. - os.Chtimes(target, now, now) + _ = os.Chtimes(target, now, now) } fmt.Println("Locale files has been successfully imported!") diff --git a/internal/cmd/restore.go b/internal/cmd/restore.go index 63d753a6..e8c82f60 100644 --- a/internal/cmd/restore.go +++ b/internal/cmd/restore.go @@ -99,7 +99,9 @@ func runRestore(c *cli.Context) error { return errors.Wrap(err, "init configuration") } - db.SetEngine() + if err = db.SetEngine(); err != nil { + return errors.Wrap(err, "set engine") + } // Database dbDir := path.Join(archivePath, "db") |