]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: force default env vars onto tool subprocesses
authorRuss Cox <rsc@golang.org>
Mon, 2 Mar 2015 01:03:49 +0000 (20:03 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 2 Mar 2015 17:52:03 +0000 (17:52 +0000)
This avoids needing every invoked tool to have an identical
computation of the build defaults as the go command does.
It makes sure the tools all know what the go command wants.

Change-Id: I484f15982bfb93c86cde8fc9df7f456505270b87
Reviewed-on: https://go-review.googlesource.com/6409
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/go/main.go

index 372f0897d08ed296c07bdd11e5b8c9efe3c5af92..a13d990cfc3df2677733565d9803202c69eb7bd0 100644 (file)
@@ -152,6 +152,15 @@ func main() {
                os.Exit(2)
        }
 
+       // Set environment (GOOS, GOARCH, etc) explicitly.
+       // In theory all the commands we invoke should have
+       // the same default computation of these as we do,
+       // but in practice there might be skew
+       // This makes sure we all agree.
+       for _, env := range mkEnv() {
+               os.Setenv(env.name, env.value)
+       }
+
        for _, cmd := range commands {
                if cmd.Name() == args[0] && cmd.Runnable() {
                        cmd.Flag.Usage = func() { cmd.Usage() }