Skip to content

Commit

Permalink
Dont ignore err in close on atomicwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Sep 10, 2024
1 parent a23fb15 commit 31aa4bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/utils/atomic-write.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func AtomicWriteFile(path string, data io.Reader, perm os.FileMode) (err error)
if err == nil {
removed := false
defer func() {
f.Close()
if err == nil {
err = f.Close()
} else {
f.Close()
}
if !removed {
os.Remove(f.Name())
removed = true
Expand Down

0 comments on commit 31aa4bc

Please sign in to comment.