Skip to content

Commit

Permalink
fix: close file after opening in SaveFileToStorage to prevent resourc…
Browse files Browse the repository at this point in the history
…e leaks
  • Loading branch information
gopkg-dev committed Nov 11, 2024
1 parent 7126e48 commit 21224dd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ func (*DefaultCtx) SaveFileToStorage(fileheader *multipart.FileHeader, path stri
if err != nil {
return fmt.Errorf("failed to open: %w", err)
}
defer file.Close()

Check failure on line 1473 in ctx.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `file.Close` is not checked (errcheck)

content, err := io.ReadAll(file)
if err != nil {
Expand Down

0 comments on commit 21224dd

Please sign in to comment.