From 10ae7c3210cd1add14d3750aa9512a87df0e1146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 18 Dec 2020 18:20:12 +0100 Subject: Improve LookPath --- tpl/internal/go_templates/testenv/testenv.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tpl/internal/go_templates/testenv/testenv.go') diff --git a/tpl/internal/go_templates/testenv/testenv.go b/tpl/internal/go_templates/testenv/testenv.go index 90044570d..f5ea398fb 100644 --- a/tpl/internal/go_templates/testenv/testenv.go +++ b/tpl/internal/go_templates/testenv/testenv.go @@ -13,7 +13,6 @@ package testenv import ( "errors" "flag" - "github.com/gohugoio/hugo/tpl/internal/go_templates/cfg" "os" "os/exec" "path/filepath" @@ -22,6 +21,9 @@ import ( "strings" "sync" "testing" + + "github.com/cli/safeexec" + "github.com/gohugoio/hugo/tpl/internal/go_templates/cfg" ) // Builder reports the name of the builder running this test @@ -111,7 +113,7 @@ func GoTool() (string, error) { if _, err := os.Stat(path); err == nil { return path, nil } - goBin, err := exec.LookPath("go" + exeSuffix) + goBin, err := safeexec.LookPath("go" + exeSuffix) if err != nil { return "", errors.New("cannot find go tool: " + err.Error()) } @@ -162,7 +164,7 @@ func MustHaveExecPath(t testing.TB, path string) { err, found := execPaths.Load(path) if !found { - _, err = exec.LookPath(path) + _, err = safeexec.LookPath(path) err, _ = execPaths.LoadOrStore(path, err) } if err != nil { -- cgit v1.2.3