mirror of
https://github.com/burrowers/garble.git
synced 2025-12-24 12:58:05 +08:00
remove err conditional that was never met
gopls correctly pointed out that the err==nil check was never met, as err was assigned and we returned early when err!=nil. This was an oversight when I wrote this; when Encode fails, we shouldn't return, because we still want to close the file. We don't defer because we want to check the error; explain that.
This commit is contained in:
@@ -128,9 +128,8 @@ func writeGobExclusive(name string, val any) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := gob.NewEncoder(f).Encode(val); err != nil {
|
||||
return err
|
||||
}
|
||||
// Always close the file, and return the first error we get.
|
||||
err = gob.NewEncoder(f).Encode(val)
|
||||
if err2 := f.Close(); err == nil {
|
||||
err = err2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user