From b38fa898c682d6d3f709e4a84710938de5b29d2d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 1 Mar 2015 20:03:49 -0500 Subject: [PATCH] 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 --- src/cmd/go/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go index 372f0897d08..a13d990cfc3 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() }