From c06a8d8ed11aae27b08c1c109a509ada9de81240 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 15 Jun 2018 22:29:15 -0400 Subject: [PATCH] imports: skip $GOPATH/src/v and $GOPATH/src/mod These are both vgo module cache locations (originally v, soon to be mod). Vgo dumps a lot of code into these directories. If goimports walks in there, it takes forever. Change-Id: I667b0a4979bf6a6b71c3651d25ec29777ff15301 Reviewed-on: https://go-review.googlesource.com/119337 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- imports/fix.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/fix.go b/imports/fix.go index ebb228d1..72bc4516 100644 --- a/imports/fix.go +++ b/imports/fix.go @@ -640,6 +640,8 @@ func scanGoDirs(which goDirType) { continue } testHookScanDir(srcDir) + srcV := filepath.Join(srcDir, "v") + srcMod := filepath.Join(srcDir, "mod") walkFn := func(path string, typ os.FileMode) error { dir := filepath.Dir(path) if typ.IsRegular() { @@ -648,6 +650,9 @@ func scanGoDirs(which goDirType) { // directly in your $GOPATH/src or $GOROOT/src. return nil } + if dir == srcV || dir == srcMod { + return filepath.SkipDir + } if !strings.HasSuffix(path, ".go") { return nil }