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>
This commit is contained in:
parent
c340431777
commit
5a00de994c
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue