Skip to content

Commit

Permalink
WIP: 456
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Aug 9, 2023
1 parent 630cdf0 commit c196d76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/goenv/goenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ruleguard/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c196d76

Please sign in to comment.