diff --git a/go/packages/golist.go b/go/packages/golist.go index dfaeed85..4b707a5e 100644 --- a/go/packages/golist.go +++ b/go/packages/golist.go @@ -548,6 +548,17 @@ func golistDriverCurrent(cfg *Config, words ...string) (*driverResponse, error) OtherFiles: absJoin(p.Dir, otherFiles(p)...), } + // Workaround for github.com/golang/go/issues/28749. + // TODO(adonovan): delete before go1.12 release. + out := pkg.CompiledGoFiles[:0] + for _, f := range pkg.CompiledGoFiles { + if strings.HasSuffix(f, ".s") { + continue + } + out = append(out, f) + } + pkg.CompiledGoFiles = out + // Extract the PkgPath from the package's ID. if i := strings.IndexByte(pkg.ID, ' '); i >= 0 { pkg.PkgPath = pkg.ID[:i] @@ -594,7 +605,9 @@ func golistDriverCurrent(cfg *Config, words ...string) (*driverResponse, error) response.Roots = append(response.Roots, pkg.ID) } - // TODO(matloob): Temporary hack since CompiledGoFiles isn't always set. + // Work around for pre-go.1.11 versions of go list. + // TODO(matloob): they should be handled by the fallback. + // Can we delete this? if len(pkg.CompiledGoFiles) == 0 { pkg.CompiledGoFiles = pkg.GoFiles } diff --git a/go/packages/stdlib_test.go b/go/packages/stdlib_test.go index ddecff1c..72665241 100644 --- a/go/packages/stdlib_test.go +++ b/go/packages/stdlib_test.go @@ -35,6 +35,9 @@ func TestStdlibMetadata(t *testing.T) { if err != nil { t.Fatalf("failed to load metadata: %v", err) } + if packages.PrintErrors(pkgs) > 0 { + t.Fatal("there were errors loading standard library") + } t1 := time.Now() runtime.GC() @@ -99,6 +102,10 @@ func TestCgoOption(t *testing.T) { t.Errorf("Load failed: %v", err) continue } + if packages.PrintErrors(pkgs) > 0 { + t.Error("there were errors loading standard library") + continue + } pkg := pkgs[0] obj := pkg.Types.Scope().Lookup(test.name) if obj == nil {