Skip to content

Commit

Permalink
go/packages: remove .s files from go list's CompiledGoFiles
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
adonovan committed Nov 13, 2018
1 parent c340431 commit 5a00de9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 14 additions & 1 deletion go/packages/golist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions go/packages/stdlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5a00de9

Please sign in to comment.