aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/testenv/testenv.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go
index cd3f43640a..e751e0cf11 100644
--- a/src/internal/testenv/testenv.go
+++ b/src/internal/testenv/testenv.go
@@ -13,6 +13,7 @@ package testenv
import (
"os"
"os/exec"
+ "path/filepath"
"runtime"
"strings"
"testing"
@@ -68,10 +69,17 @@ func MustHaveGoRun(t *testing.T) {
// If the tool should be available and isn't, GoToolPath calls t.Fatal.
func GoToolPath(t *testing.T) string {
MustHaveGoBuild(t)
+
var exeSuffix string
if runtime.GOOS == "windows" {
exeSuffix = ".exe"
}
+
+ path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
+ if _, err := os.Stat(path); err == nil {
+ return path
+ }
+
goBin, err := exec.LookPath("go" + exeSuffix)
if err != nil {
t.Fatalf("cannot find go tool: %v", err)