Skip to content

Commit b38fa89

Browse files
committed
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 <r@golang.org>
1 parent deff22d commit b38fa89

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cmd/go/main.go

+9
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ func main() {
152152
os.Exit(2)
153153
}
154154

155+
// Set environment (GOOS, GOARCH, etc) explicitly.
156+
// In theory all the commands we invoke should have
157+
// the same default computation of these as we do,
158+
// but in practice there might be skew
159+
// This makes sure we all agree.
160+
for _, env := range mkEnv() {
161+
os.Setenv(env.name, env.value)
162+
}
163+
155164
for _, cmd := range commands {
156165
if cmd.Name() == args[0] && cmd.Runnable() {
157166
cmd.Flag.Usage = func() { cmd.Usage() }

0 commit comments

Comments
 (0)