1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:14:39 -07:00

cmd/toolstash: use "go env GOROOT" instead of runtime.GOROOT()

The GOROOT of whatever tool build toolstash is irrelevant. We want
the goroot of the "go" command we're testing.

Change-Id: Ie7e11c74cb445ea694d88c743dbc239a55d47864
Reviewed-on: https://go-review.googlesource.com/43033
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Keith Randall 2017-05-09 12:41:43 -07:00 committed by Keith Randall
parent a6971f4c11
commit 1dbffd0798

View File

@ -156,6 +156,7 @@ func usage() {
}
var (
goCmd = flag.String("go", "go", "path to \"go\" command")
norun = flag.Bool("n", false, "print but do not run commands")
verbose = flag.Bool("v", false, "print commands being run")
cmp = flag.Bool("cmp", false, "compare tool object files")
@ -199,7 +200,11 @@ func main() {
usage()
}
goroot = runtime.GOROOT()
s, err := exec.Command(*goCmd, "env", "GOROOT").CombinedOutput()
if err != nil {
log.Fatalf("%s env GOROOT: %v", *goCmd, err)
}
goroot = strings.TrimSpace(string(s))
toolDir = filepath.Join(goroot, fmt.Sprintf("pkg/tool/%s_%s", runtime.GOOS, runtime.GOARCH))
stashDir = filepath.Join(goroot, "pkg/toolstash")
@ -248,7 +253,7 @@ func main() {
xcmd.Stdin = os.Stdin
xcmd.Stdout = os.Stdout
xcmd.Stderr = os.Stderr
err := xcmd.Run()
err = xcmd.Run()
if err != nil {
log.Fatal(err)
}