Commit d778a371 authored by Shivansh Rai's avatar Shivansh Rai Committed by Brad Fitzpatrick

cmd/gofmt: update error handling when writing to backup file

As per commit aa0ae755, handling of io.ErrShortWrite is done in
*File.Write() itself.

Change-Id: I92924b51e8df2ae88e6e50318348f44973addba8
Reviewed-on: https://go-review.googlesource.com/113696Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent c92354f4
...@@ -319,10 +319,7 @@ func backupFile(filename string, data []byte, perm os.FileMode) (string, error) ...@@ -319,10 +319,7 @@ func backupFile(filename string, data []byte, perm os.FileMode) (string, error)
} }
// write data to backup file // write data to backup file
n, err := f.Write(data) _, err = f.Write(data)
if err == nil && n < len(data) {
err = io.ErrShortWrite
}
if err1 := f.Close(); err == nil { if err1 := f.Close(); err == nil {
err = err1 err = err1
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment