Skip to content

Commit 384b9f7

Browse files
author
Kai Kummerer
committed
correctly handle f.Close error
1 parent db8f4ad commit 384b9f7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/pkg/config/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ func InitConfig() {
9191
cobra.CheckErr(err)
9292
}
9393
}
94-
defer f.Close() //nolint:errcheck // file close errors are hard to handle
94+
defer func() {
95+
if f != nil {
96+
if err := f.Close(); err != nil {
97+
cobra.CheckErr(err)
98+
}
99+
}
100+
}()
95101

96102
setConfigDefaults()
97103

0 commit comments

Comments
 (0)