Commit a5032bc8 authored by james's avatar james Committed by Brad Fitzpatrick

os: don't leak file in ExampleOpenFile_append failure path

Fixes #31424

Change-Id: I8364578cbc77827552bd764c716f68495ec51547
Reviewed-on: https://go-review.googlesource.com/c/go/+/171763Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ccaa4913
......@@ -28,6 +28,7 @@ func ExampleOpenFile_append() {
log.Fatal(err)
}
if _, err := f.Write([]byte("appended some data\n")); err != nil {
f.Close() // ignore error; Write error takes precedence
log.Fatal(err)
}
if err := f.Close(); err != nil {
......
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