1
0
mirror of https://github.com/golang/go synced 2024-11-18 13:04:46 -07:00

go/internal/packagesdriver: fix crash when GOARCH and Go compiler can't be determined

When run "go list" outside GOPATH, result should be empty

Change-Id: If832c46d3e4c32a2a87338cca95e3169ea3be055
Reviewed-on: https://go-review.googlesource.com/c/155557
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Yasuhiro Matsumoto 2018-12-21 10:22:55 +09:00 committed by Michael Matloob
parent d00ac6d273
commit 79186431cf

View File

@ -86,6 +86,9 @@ func GetSizesGolist(ctx context.Context, buildFlags, env []string, dir string, u
return nil, err
}
fields := strings.Fields(stdout.String())
if len(fields) < 2 {
return nil, fmt.Errorf("could not determine GOARCH and Go compiler")
}
goarch := fields[0]
compiler := fields[1]
return types.SizesFor(compiler, goarch), nil