From 79186431cf2917562ba2e632326924b5594ce114 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 21 Dec 2018 10:22:55 +0900 Subject: [PATCH] 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 --- go/internal/packagesdriver/sizes.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go/internal/packagesdriver/sizes.go b/go/internal/packagesdriver/sizes.go index eecf07fee9..fdc7da0568 100644 --- a/go/internal/packagesdriver/sizes.go +++ b/go/internal/packagesdriver/sizes.go @@ -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