diff --git a/src/pkg/io/ioutil/ioutil.go b/src/pkg/io/ioutil/ioutil.go index 6b395c69bd..ce8d8b48ac 100644 --- a/src/pkg/io/ioutil/ioutil.go +++ b/src/pkg/io/ioutil/ioutil.go @@ -78,10 +78,12 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error { return err } n, err := f.Write(data) - f.Close() if err == nil && n < len(data) { err = io.ErrShortWrite } + if err1 := f.Close(); err == nil { + err = err1 + } return err }