1
0
mirror of https://github.com/golang/go synced 2024-11-19 22:04:44 -07:00

cmd/internal/buildid: add missing f.Close in ReadFile

On Windows, not closing f keeps us from being able to remove it.

Change-Id: Id4cb709b6ce0b30485b87364a9f0e6e71d2782bd
Reviewed-on: https://go-review.googlesource.com/70070
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Russ Cox 2017-10-11 15:14:53 -04:00
parent 31896332b3
commit 7dcd33302a

View File

@ -33,6 +33,7 @@ func ReadFile(name string) (id string, err error) {
if err != nil {
return "", err
}
defer f.Close()
buf := make([]byte, 8)
if _, err := f.ReadAt(buf, 0); err != nil {
@ -54,8 +55,6 @@ func ReadFile(name string) (id string, err error) {
// Reading the first 1024 bytes should be plenty.
data := make([]byte, 1024)
n, err := io.ReadFull(f, data)
f.Close()
if err != nil && n == 0 {
return "", err
}