From 50c59194758999487f577030ca11d91c65530559 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Tue, 1 Nov 2022 16:14:06 -0400 Subject: [PATCH] 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 #47257 Change-Id: I315ad87d0a9182e00ae4c11b82986227e2b02e17 Reviewed-on: https://go-review.googlesource.com/c/go/+/447115 TryBot-Result: Gopher Robot Reviewed-by: Michael Matloob Run-TryBot: Michael Matloob Reviewed-by: Bryan Mills --- src/cmd/dist/build.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 605ef52e96..dfa67290fa 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -481,22 +481,22 @@ func setup() { // We used to use it for C objects. // Now we use it for the build cache, to separate dist's cache // from any other cache the user might have. - p = pathf("%s/pkg/obj/go-build", goroot) + objGobuild := pathf("%s/pkg/obj/go-build", goroot) if rebuildall { - xremoveall(p) + xremoveall(objGobuild) } - xmkdirall(p) - xatexit(func() { xremoveall(p) }) + xmkdirall(objGobuild) + xatexit(func() { xremoveall(objGobuild) }) // Create alternate driectory for intermediate // standard library .a's to be placed rather than // the final build's install locations. - p = pathf("%s/pkg/obj/go-bootstrap", goroot) + objGoBootstrap := pathf("%s/pkg/obj/go-bootstrap", goroot) if rebuildall { - xremoveall(p) + xremoveall(objGoBootstrap) } - xmkdirall(p) - xatexit(func() { xremoveall(p) }) + xmkdirall(objGoBootstrap) + xatexit(func() { xremoveall(objGoBootstrap) }) // Create tool directory. // We keep it in pkg/, just like the object directory above.