Skip to content

Commit 87913b6

Browse files
iPraveenPariharmergify[bot]
authored andcommitted
fix: check error return value of log file Close
Address errcheck lint failure by wrapping f.Close() in a deferred closure that checks and logs the error. Signed-off-by: Praveen M <m.praveen@ibm.com>
1 parent 19466a5 commit 87913b6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

sidecar/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ func main() {
125125
fmt.Fprintf(os.Stderr, "failed to open log file %q: %v\n", *logFile, err)
126126
os.Exit(1)
127127
}
128-
defer f.Close()
128+
defer func() {
129+
if err := f.Close(); err != nil {
130+
fmt.Fprintf(os.Stderr, "failed to close log file %q: %v\n", *logFile, err)
131+
}
132+
}()
129133
zapOpts = append(zapOpts, zap.WriteTo(io.MultiWriter(os.Stderr, f)))
130134
}
131135
ctrl.SetLogger(zap.New(zapOpts...))

0 commit comments

Comments
 (0)