diff --git a/go/packages/golist_fallback.go b/go/packages/golist_fallback.go index 21cffac7..55fe8058 100644 --- a/go/packages/golist_fallback.go +++ b/go/packages/golist_fallback.go @@ -304,7 +304,10 @@ func cleanAbsPaths(cfg *Config, words []string) []string { var cleaned = make([]string, len(words)) for i := range cleaned { cleaned[i] = words[i] - if !filepath.IsAbs(cleaned[i]) { + // Ignore relative directory paths (they must already be goroot-relative) and Go source files + // (absolute source files are already allowed for ad-hoc packages). + // TODO(matloob): Can there be non-.go files in ad-hoc packages. + if !filepath.IsAbs(cleaned[i]) || strings.HasSuffix(cleaned[i], ".go") { continue } // otherwise, it's an absolute path. Search GOPATH and GOROOT to find it. diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go index a91633d4..ff485e7b 100644 --- a/go/packages/packages_test.go +++ b/go/packages/packages_test.go @@ -202,7 +202,7 @@ func TestLoadImportsGraph(t *testing.T) { t.Errorf("failed to obtain metadata for ad-hoc package: %s", err) } else { got := fmt.Sprintf("%s %s", initial[0].ID, srcs(initial[0])) - if want := "command-line-arguments [c.go]"; got != want && !usesOldGolist { + if want := "command-line-arguments [c.go]"; got != want { t.Errorf("oops: got %s, want %s", got, want) } }