go.tools/imports: use same logic as 'go' tool for pruning package search.

The previous logic would descend into "_"-prefixed names, "testdata" folders,
and skipped folders beginning with a digit.

Fixes golang/go#8958.

LGTM=bradfitz
R=golang-codereviews, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/167000043
This commit is contained in:
Dmitri Shuralyov 2014-11-12 12:45:17 -08:00 committed by Brad Fitzpatrick
parent c097262a24
commit a26eca502f
1 changed files with 2 additions and 4 deletions

View File

@ -239,11 +239,9 @@ func loadPkg(wg *sync.WaitGroup, root, pkgrelpath string) {
// then the calls to importPathToName below can be expensive.
hasGo := false
for _, child := range children {
// Avoid .foo, _foo, and testdata directory trees.
name := child.Name()
if name == "" {
continue
}
if c := name[0]; c == '.' || ('0' <= c && c <= '9') {
if name == "" || name[0] == '.' || name[0] == '_' || name == "testdata" {
continue
}
if strings.HasSuffix(name, ".go") {