Skip to content

Commit 108df66

Browse files
matloobromaindoumenc
authored andcommitted
cmd/dist: fix a variable scope bug:
We reused p so we were deleting the same directory twice instead of two different directories. Fix that. For golang#47257 Change-Id: I315ad87d0a9182e00ae4c11b82986227e2b02e17 Reviewed-on: https://go-review.googlesource.com/c/go/+/447115 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Run-TryBot: Michael Matloob <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent de69284 commit 108df66

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/cmd/dist/build.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -481,22 +481,22 @@ func setup() {
481481
// We used to use it for C objects.
482482
// Now we use it for the build cache, to separate dist's cache
483483
// from any other cache the user might have.
484-
p = pathf("%s/pkg/obj/go-build", goroot)
484+
objGobuild := pathf("%s/pkg/obj/go-build", goroot)
485485
if rebuildall {
486-
xremoveall(p)
486+
xremoveall(objGobuild)
487487
}
488-
xmkdirall(p)
489-
xatexit(func() { xremoveall(p) })
488+
xmkdirall(objGobuild)
489+
xatexit(func() { xremoveall(objGobuild) })
490490

491491
// Create alternate driectory for intermediate
492492
// standard library .a's to be placed rather than
493493
// the final build's install locations.
494-
p = pathf("%s/pkg/obj/go-bootstrap", goroot)
494+
objGoBootstrap := pathf("%s/pkg/obj/go-bootstrap", goroot)
495495
if rebuildall {
496-
xremoveall(p)
496+
xremoveall(objGoBootstrap)
497497
}
498-
xmkdirall(p)
499-
xatexit(func() { xremoveall(p) })
498+
xmkdirall(objGoBootstrap)
499+
xatexit(func() { xremoveall(objGoBootstrap) })
500500

501501
// Create tool directory.
502502
// We keep it in pkg/, just like the object directory above.

0 commit comments

Comments
 (0)