diff --git a/go/packages/golist.go b/go/packages/golist.go index d3ead604fd2..b4f3cd1addf 100644 --- a/go/packages/golist.go +++ b/go/packages/golist.go @@ -287,8 +287,14 @@ func golistargs(cfg *Config, words []string) []string { // golist returns the JSON-encoded result of a "go list args..." query. func golist(cfg *Config, args []string) (*bytes.Buffer, error) { + goBin := "go" + for _, e := range cfg.Env { + if strings.HasPrefix(e, "GOCMD=") && len(e) > 6 { + goBin = e[6:] + } + } out := new(bytes.Buffer) - cmd := exec.CommandContext(cfg.Context, "go", args...) + cmd := exec.CommandContext(cfg.Context, goBin, args...) cmd.Env = cfg.Env cmd.Dir = cfg.Dir cmd.Stdout = out