Commit 821e3f7d authored by Alex Brainman's avatar Alex Brainman

cmd/go: close unintentionally left open file

cmd/go/internal/work.Builder.updateBuildID left a file opened.
But opened files cannot be deleted on Windows, so cmd/go just
leaves these files in %TMP% directory.

Close the file so deletion can succeed.

Fixes #22650

Change-Id: Ia3ea62f6ec7208d73972eae2e17fb4a766407914
Reviewed-on: https://go-review.googlesource.com/76810Reviewed-by: default avatarDave Cheney <dave@cheney.net>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent bdf30565
...@@ -448,6 +448,7 @@ func (b *Builder) updateBuildID(a *Action, target string, rewrite bool) error { ...@@ -448,6 +448,7 @@ func (b *Builder) updateBuildID(a *Action, target string, rewrite bool) error {
r, err := os.Open(target) r, err := os.Open(target)
if err == nil { if err == nil {
c.Put(a.actionID, r) c.Put(a.actionID, r)
r.Close()
} }
} }
......
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