From 2248f99be34d19e34a64b754e87ff2f8a3ebcfce Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Wed, 10 Apr 2024 15:13:23 -0700 Subject: [PATCH] feat: pass environment to go compiler Signed-off-by: Christian Stewart --- pkg/goweight.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/goweight.go b/pkg/goweight.go index d9bfe25..ce01c0a 100644 --- a/pkg/goweight.go +++ b/pkg/goweight.go @@ -1,7 +1,6 @@ package pkg import ( - "io/ioutil" "log" "os" "os/exec" @@ -17,7 +16,9 @@ import ( var moduleRegex = regexp.MustCompile("packagefile (.*)=(.*)") func run(cmd []string) string { - out, err := exec.Command(cmd[0], cmd[1:]...).CombinedOutput() + c := exec.Command(cmd[0], cmd[1:]...) + c.Env = append([]string{}, os.Environ()...) + out, err := c.CombinedOutput() if err != nil { log.Fatal(err) } @@ -71,7 +72,7 @@ func (g *GoWeight) Process(work string) []*ModuleEntry { } allLines := funk.Uniq(funk.FlattenDeep(funk.Map(files, func(file string) []string { - f, err := ioutil.ReadFile(file) + f, err := os.ReadFile(file) if err != nil { return []string{} }