go/packages: remove .s files from go list's CompiledGoFiles

This is a workaround for a go list regression that broke
go/packages but went unnoticed by because of a missing
call to packages.PrintErrors, added here.

Updates golang/go#28749

Change-Id: I1819a6143134a422791106ac037d3458ef864322
Reviewed-on: https://go-review.googlesource.com/c/149237
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/go/packages/golist.go b/go/packages/golist.go
index dfaeed8..4b707a5 100644
--- a/go/packages/golist.go
+++ b/go/packages/golist.go
@@ -548,6 +548,17 @@
 			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 @@
 			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 ddecff1..7266524 100644
--- a/go/packages/stdlib_test.go
+++ b/go/packages/stdlib_test.go
@@ -35,6 +35,9 @@
 	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 @@
 			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 {