Commit e832043e authored by Russ Cox's avatar Russ Cox

cmd/go: set $GOROOT during 'go tool' invocations

cmd/dist now requires $GOROOT to be set explicitly.
Set it when invoking via 'go tool dist' so that users are unaffected.

Also, change go tool -n to drop trailing space in output
for 'go tool -n <anything>'.

Change-Id: I9b2c020e0a2f3fa7c9c339fadcc22cc5b6cb7cac
Reviewed-on: https://go-review.googlesource.com/3011Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent dca54d7c
......@@ -92,7 +92,11 @@ func runTool(cmd *Command, args []string) {
return
}
if toolN {
fmt.Printf("%s %s\n", toolPath, strings.Join(args[1:], " "))
cmd := toolPath
if len(args) > 1 {
cmd += " " + strings.Join(args[1:], " ")
}
fmt.Printf("%s\n", cmd)
return
}
toolCmd := &exec.Cmd{
......@@ -101,6 +105,8 @@ func runTool(cmd *Command, args []string) {
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
// Set $GOROOT, mainly for go tool dist.
Env: mergeEnvLists([]string{"GOROOT=" + goroot}, os.Environ()),
}
err := toolCmd.Run()
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment