chore: upgrade golangci-lint

This commit is contained in:
Oleg Lobanov
2021-07-26 12:00:05 +02:00
parent 201329abce
commit 34d7d2c8c4
17 changed files with 37 additions and 45 deletions

View File

@@ -9,10 +9,11 @@ import (
"path/filepath"
"strings"
"github.com/mholt/archiver"
"github.com/filebrowser/filebrowser/v2/files"
"github.com/filebrowser/filebrowser/v2/fileutils"
"github.com/filebrowser/filebrowser/v2/users"
"github.com/mholt/archiver"
)
func slashClean(name string) string {

View File

@@ -97,7 +97,7 @@ func resourcePostHandler(fileCache FileCache) handleFunc {
// Directories creation on POST.
if strings.HasSuffix(r.URL.Path, "/") {
err := d.user.Fs.MkdirAll(r.URL.Path, 0775)
err := d.user.Fs.MkdirAll(r.URL.Path, 0775) //nolint:gomnd
return errToStatus(err), err
}
@@ -255,12 +255,12 @@ func addVersionSuffix(source string, fs afero.Fs) string {
func writeFile(fs afero.Fs, dst string, in io.Reader) (os.FileInfo, error) {
dir, _ := path.Split(dst)
err := fs.MkdirAll(dir, 0775)
err := fs.MkdirAll(dir, 0775) //nolint:gomnd
if err != nil {
return nil, err
}
file, err := fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775)
file, err := fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775) //nolint:gomnd
if err != nil {
return nil, err
}

View File

@@ -90,7 +90,7 @@ var sharePostHandler = withPermShare(func(w http.ResponseWriter, r *http.Request
defer r.Body.Close()
}
bytes := make([]byte, 6)
bytes := make([]byte, 6) //nolint:gomnd
_, err := rand.Read(bytes)
if err != nil {
return http.StatusInternalServerError, err
@@ -129,7 +129,7 @@ var sharePostHandler = withPermShare(func(w http.ResponseWriter, r *http.Request
var token string
if len(hash) > 0 {
tokenBuffer := make([]byte, 96)
tokenBuffer := make([]byte, 96) //nolint:gomnd
if _, err := rand.Read(tokenBuffer); err != nil {
return http.StatusInternalServerError, err
}

View File

@@ -25,7 +25,7 @@ type modifyUserRequest struct {
func getUserID(r *http.Request) (uint, error) {
vars := mux.Vars(r)
i, err := strconv.ParseUint(vars["id"], 10, 0)
i, err := strconv.ParseUint(vars["id"], 10, 0) //nolint:gomnd
if err != nil {
return 0, err
}
@@ -138,7 +138,7 @@ var userPostHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *
return http.StatusInternalServerError, err
}
w.Header().Set("Location", "/settings/users/"+strconv.FormatUint(uint64(req.Data.ID), 10))
w.Header().Set("Location", "/settings/users/"+strconv.FormatUint(uint64(req.Data.ID), 10)) //nolint:gomnd
return http.StatusCreated, nil
})