You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These linting errors were surfaced from an upgraded golangci-lint:
internal/config/file.go:43:3: G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
defer func() {
if err := fh.Close(); err != nil {
// Ignore "file already closed" errors
if !errors.Is(err, os.ErrClosed) {
c.Log.Error().Msgf(
"failed to close file %q: %s",
file,
err.Error(),
)
}
}
}()
internal/files/report.go:103:2: G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
defer func(filename string) {
if err := f.Close(); err != nil {
// Ignore "file already closed" errors
if !errors.Is(err, os.ErrClosed) {
logger.Error().
Err(err).
Str("filename", filename).
Msg("failed to close file")
}
}
}(reportFilePath)
cmd/list-emails/main.go:65:2: G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
defer func(filename string) {
if err := cfg.LogFileHandle.Close(); err != nil {
// Ignore "file already closed" errors
if !errors.Is(err, os.ErrClosed) {
// We're using the standalone Err function from rs/zerolog/log
// as we have the main logger set to write to a log file,
// which we just failed to close. By default, this message
// will go to stderr and should be decipherable by the user.
zlog.Error().
Err(err).
Str("filename", filename).
Msg("failed to close file")
}
}
}(cfg.LogFileHandle.Name())
The text was updated successfully, but these errors were encountered:
Issues reported after upgrading golangci-lint to v1.43.0.
gosec was updated in that version from v2.8.1 to v2.9.1.
refs #234
refs golangci/golangci-lint#2299
atc0005
changed the title
G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
(false positive) G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
Nov 8, 2021
atc0005
changed the title
(false positive) G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
False positive G307: Deferring unsafe method "Close" on type "*os.File" (gosec) linting error
Nov 8, 2021
These linting errors were surfaced from an upgraded
golangci-lint
:The text was updated successfully, but these errors were encountered: