From: Josh Bleecher Snyder Date: Mon, 6 May 2019 16:18:08 +0000 (-0700) Subject: cmd/dist: delete unnecessary dirs from GOROOT on completion X-Git-Tag: go1.13beta1~412 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a921881f85e3b947a541315d25bf27a3608d29e4;p=gostls13.git cmd/dist: delete unnecessary dirs from GOROOT on completion On my machine, these directories add up to 276mb and account for 40% of the size of the GOROOT directory. Once bootstrapping is complete, they are never used again. Fixes #31851 Change-Id: Idbf8f21bae3d64655aa43761cc778677add6234a Reviewed-on: https://go-review.googlesource.com/c/go/+/175377 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 2af6a2dd1b..3df7f09abc 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -496,6 +496,7 @@ func setup() { xremoveall(p) } xmkdirall(p) + xatexit(func() { xremoveall(p) }) // Create tool directory. // We keep it in pkg/, just like the object directory above. diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go index 26e12991a4..190b592b6e 100644 --- a/src/cmd/dist/buildtool.go +++ b/src/cmd/dist/buildtool.go @@ -128,6 +128,7 @@ func bootstrapBuildTools() { // but it is easier to debug on failure if the files are in a known location. workspace := pathf("%s/pkg/bootstrap", goroot) xremoveall(workspace) + xatexit(func() { xremoveall(workspace) }) base := pathf("%s/src/bootstrap", workspace) xmkdirall(base)