Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 19.09 35 lines 1.2 kB view raw
1diff --git a/src/go/build/build.go b/src/go/build/build.go 2index d8163d0172..dd80a70473 100644 3--- a/src/go/build/build.go 4+++ b/src/go/build/build.go 5@@ -1592,7 +1592,7 @@ func init() { 6 } 7 8 // ToolDir is the directory containing build tools. 9-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) 10+var ToolDir = runtime.GOTOOLDIR() 11 12 // IsLocalImport reports whether the import path is 13 // a local import path, like ".", "..", "./foo", or "../foo". 14diff --git a/src/runtime/extern.go b/src/runtime/extern.go 15index 6e6c674d96..e9f62f96dc 100644 16--- a/src/runtime/extern.go 17+++ b/src/runtime/extern.go 18@@ -223,6 +223,17 @@ func GOROOT() string { 19 return sys.DefaultGoroot 20 } 21 22+// GOTOOLDIR returns the root of the Go tree. 23+// It uses the GOTOOLDIR environment variable, if set, 24+// or else the root used during the Go build. 25+func GOTOOLDIR() string { 26+ s := gogetenv("GOTOOLDIR") 27+ if s != "" { 28+ return s 29+ } 30+ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH 31+} 32+ 33 // Version returns the Go tree's version string. 34 // It is either the commit hash and date at the time of the build or, 35 // when possible, a release tag like "go1.3".