Partial revert of https://golang.org/cl/20967 which
I can't reproduce and actually breaks me more.
Fixes #14901
Change-Id: I8cce443fbd95f5f6f2a5b6a4b9f2faab36167a12
Reviewed-on: https://go-review.googlesource.com/21292
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
import (
"os"
"os/exec"
+ "path/filepath"
"runtime"
"strings"
"testing"
// 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)