diff --git a/internal/goenv/goenv.go b/internal/goenv/goenv.go index 095e874..b64e5aa 100644 --- a/internal/goenv/goenv.go +++ b/internal/goenv/goenv.go @@ -6,12 +6,12 @@ import ( "strings" ) -func Read(varNames []string) (map[string]string, error) { - out, err := exec.Command("go", append([]string{"env"}, varNames...)...).CombinedOutput() +func Read() (map[string]string, error) { + out, err := exec.Command("go", "env", "GOROOT", "GOPATH", "GOARCH", "GOOS", "CGO_ENABLED").CombinedOutput() if err != nil { return nil, err } - return parseGoEnv(varNames, out) + return parseGoEnv([]string{"GOROOT", "GOPATH", "GOARCH", "GOOS", "CGO_ENABLED"}, out) } func parseGoEnv(varNames []string, data []byte) (map[string]string, error) { diff --git a/ruleguard/engine.go b/ruleguard/engine.go index b51b2e7..e4cf954 100644 --- a/ruleguard/engine.go +++ b/ruleguard/engine.go @@ -247,7 +247,7 @@ func inferBuildContext() *build.Context { // Inherit most fields from the build.Default. ctx := build.Default - env, err := goenv.Read([]string{"GOROOT", "GOPATH", "GOARCH", "GOOS", "CGO_ENABLED"}) + env, err := goenv.Read() if err != nil { return &ctx }