Return the err from f.Close()
In the case of an EIO (IO Exception) the error from the write would be
lost because of the use of defer.
See
@@ -381,12 +381,13 @@ func (n *linuxNetwork) setProcSys(key, value string) error {
if err != nil {
return err
}
- defer f.Close()
_, err = f.WriteString(value)
if err != nil {
+ // If the write failed, just close
+ _ = f.Close()
return err
}
- return nil
+ return f.Close()
}
type iptablesRule struct {
