From: Russ Cox Date: Mon, 2 Mar 2015 01:03:49 +0000 (-0500) Subject: cmd/go: force default env vars onto tool subprocesses X-Git-Tag: go1.5beta1~1777 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b38fa898c682d6d3f709e4a84710938de5b29d2d;p=gostls13.git cmd/go: force default env vars onto tool subprocesses 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 --- diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go index 372f0897d0..a13d990cfc 100644 --- a/src/cmd/go/main.go +++ b/src/cmd/go/main.go @@ -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() }