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:
parent
d00ac6d273
commit
79186431cf
|
@ -86,6 +86,9 @@ func GetSizesGolist(ctx context.Context, buildFlags, env []string, dir string, u
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fields := strings.Fields(stdout.String())
|
fields := strings.Fields(stdout.String())
|
||||||
|
if len(fields) < 2 {
|
||||||
|
return nil, fmt.Errorf("could not determine GOARCH and Go compiler")
|
||||||
|
}
|
||||||
goarch := fields[0]
|
goarch := fields[0]
|
||||||
compiler := fields[1]
|
compiler := fields[1]
|
||||||
return types.SizesFor(compiler, goarch), nil
|
return types.SizesFor(compiler, goarch), nil
|
||||||
|
|
Loading…
Reference in New Issue