Skip to content

Commit

Permalink
chore: introduce linters and remove unused code in file handling func…
Browse files Browse the repository at this point in the history
…tions

- Add `gosec` and `revive` linters
- Remove unnecessary argument from `Readdir` function
- Remove unused `err` variable in `defaultHandleRecovery` function

Signed-off-by: appleboy <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Apr 26, 2023
1 parent fe989b6 commit ec42110
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ issues:
- path: _test\.go
linters:
- gosec # security is not make sense in tests
- path: gin.go
linters:
- gosec
- linters:
- revive
path: _test\.go
2 changes: 1 addition & 1 deletion fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (fs onlyFilesFS) Open(name string) (http.File, error) {
}

// Readdir overrides the http.File default implementation.
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
func (f neuteredReaddirFile) Readdir(_ int) ([]os.FileInfo, error) {
// this disables directory listing
return nil, nil
}
2 changes: 1 addition & 1 deletion recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
}
}

func defaultHandleRecovery(c *Context, err any) {
func defaultHandleRecovery(c *Context, _ any) {
c.AbortWithStatus(http.StatusInternalServerError)
}

Expand Down

0 comments on commit ec42110

Please sign in to comment.