according to https://www.joeshaw.org/dont-defer-close-on-writable-files/ one should not use defer file.close(), its a bad pattern
This commit is contained in:
parent
46fe6bc6cb
commit
3b153c7d80
@ -40,5 +40,9 @@ func writeFile(f *os.File) {
|
||||
|
||||
func closeFile(f *os.File) {
|
||||
fmt.Println("closing")
|
||||
f.Close()
|
||||
err := f.Close()
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user