mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
io/ioutil: make WriteFile notice errors from Close()
WriteFile should not successfully return if the file's Close call failed. Fixes #5644. R=golang-dev, kr, r CC=golang-dev https://golang.org/cl/10067043
This commit is contained in:
parent
6bf6cae28e
commit
9614119007
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue