cmd/release: remove go/pkg/${GOOS}_${GOARCH}/cmd from releases

This saves a bunch of space, and users don't typically rebuild
cmd/compile, cmd/link, etc. If they want to, they still can, but
they'll have to pay the cost of rebuilding dependent libaries. No need
to ship them just in case.

On linux-amd64, this reduces the tar.gz size from 177,294,517 to
156,487,264 bytes, a 19.8 MiB, 12% reduction.

Change-Id: I784dcf2c6f15f8eee8b9eaa501a8d982b2627288
Reviewed-on: https://go-review.googlesource.com/129955
Reviewed-by: Andrew Bonventre <andybons@golang.org>
diff --git a/cmd/release/release.go b/cmd/release/release.go
index 381591e..7b624c5 100644
--- a/cmd/release/release.go
+++ b/cmd/release/release.go
@@ -34,7 +34,7 @@
 )
 
 var (
-	target = flag.String("target", "", "If specified, build specific target platform ('linux-amd64')")
+	target = flag.String("target", "", "If specified, build specific target platform (e.g. 'linux-amd64'). Default is to build all.")
 	watch  = flag.Bool("watch", false, "Watch the build. Only compatible with -target")
 
 	rev       = flag.String("rev", "", "Go revision to build")
@@ -153,6 +153,7 @@
 }
 
 func (b *Build) toolDir() string { return "go/pkg/tool/" + b.OS + "_" + b.Arch }
+func (b *Build) pkgDir() string  { return "go/pkg/" + b.OS + "_" + b.Arch }
 
 func (b *Build) logf(format string, args ...interface{}) {
 	format = fmt.Sprintf("%v: %s", b, format)
@@ -436,9 +437,19 @@
 	if err := client.RemoveAll(addPrefix(goDir, postBuildCleanFiles)...); err != nil {
 		return err
 	}
+	// Users don't need the api checker binary pre-built. It's
+	// used by tests, but all.bash builds it first.
 	if err := client.RemoveAll(b.toolDir() + "/api"); err != nil {
 		return err
 	}
+	// Remove go/pkg/${GOOS}_${GOARCH}/cmd. This saves a bunch of
+	// space, and users don't typically rebuild cmd/compile,
+	// cmd/link, etc. If they want to, they still can, but they'll
+	// have to pay the cost of rebuilding dependent libaries. No
+	// need to ship them just in case.
+	if err := client.RemoveAll(b.pkgDir() + "/cmd"); err != nil {
+		return err
+	}
 
 	b.logf("Pushing and running releaselet.")
 	f, err := os.Open(releaselet)