From a26eca502f195faceb8dbe35a82b1e2e86a0d00a Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Wed, 12 Nov 2014 12:45:17 -0800 Subject: [PATCH] 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 --- imports/fix.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/imports/fix.go b/imports/fix.go index 11415cfc..6f441aaa 100644 --- a/imports/fix.go +++ b/imports/fix.go @@ -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") {