mirror of
https://github.com/golang/go
synced 2024-11-17 13:54:46 -07:00
os: don't leak file in ExampleOpenFile_append failure path
Fixes #31424 Change-Id: I8364578cbc77827552bd764c716f68495ec51547 Reviewed-on: https://go-review.googlesource.com/c/go/+/171763 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
ccaa491386
commit
a5032bc86c
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user