diff --git a/go/packages/packages.go b/go/packages/packages.go index 9c786490da..a1ceb8b9c2 100644 --- a/go/packages/packages.go +++ b/go/packages/packages.go @@ -17,9 +17,10 @@ import ( "os" "sync" - "golang.org/x/tools/go/gcexportdata" "path/filepath" "strings" + + "golang.org/x/tools/go/gcexportdata" ) // A LoadMode specifies the amount of detail to return when loading packages. @@ -296,11 +297,6 @@ func (ld *loader) load(patterns ...string) ([]*Package, error) { // See if the extra process invocation can be avoided. list, err := listfunc(rawCfg, patterns...) if _, ok := err.(GoTooOldError); ok { - if ld.Config.Mode >= LoadTypes { - // Upgrade to LoadAllSyntax because we can't depend on the existance - // of export data. We can remove this once iancottrell's cl is in. - ld.Config.Mode = LoadAllSyntax - } listfunc = golistPackagesFallback list, err = listfunc(rawCfg, patterns...) } @@ -358,8 +354,7 @@ func (ld *loader) loadFrom(list ...*rawPackage) ([]*Package, error) { GoFiles: pkg.GoFiles, OtherFiles: pkg.OtherFiles, }, - // TODO: should needsrc also be true if pkg.Export == "" - needsrc: ld.Mode >= LoadAllSyntax, + needsrc: ld.Mode >= LoadAllSyntax || pkg.Export == "", } ld.pkgs[lpkg.ID] = lpkg if !pkg.DepOnly { diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go index 66953e6853..0d4780e740 100644 --- a/go/packages/packages_test.go +++ b/go/packages/packages_test.go @@ -533,13 +533,12 @@ func TestTypeCheckError(t *testing.T) { wantTypes bool wantSyntax bool wantIllTyped bool - wantErrs []string }{ - {"a", true, true, true, nil}, - {"b", true, true, true, nil}, - {"c", true, true, true, []string{"could not import d (no export data file)"}}, - {"d", false, false, true, nil}, // missing export data - {"e", false, false, false, nil}, // type info not requested (despite type error) + {"a", true, true, true}, + {"b", true, true, true}, + {"c", true, true, true}, + {"d", false, false, true}, // missing export data + {"e", false, false, false}, // type info not requested (despite type error) } { if usesOldGolist && test.id == "c" || test.id == "d" || test.id == "e" { // Behavior is different for old golist because it upgrades to wholeProgram. @@ -568,9 +567,6 @@ func TestTypeCheckError(t *testing.T) { if p.IllTyped != test.wantIllTyped { t.Errorf("IllTyped was %t for %s", p.IllTyped, test.id) } - if errs := errorMessages(p.Errors); !reflect.DeepEqual(errs, test.wantErrs) { - t.Errorf("in package %s, got errors %s, want %s", p, errs, test.wantErrs) - } } // Check value of constant.