From 42c3d2e9aae13638ff117fbcbeb63f06dd5393ba Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Wed, 7 Nov 2018 14:55:33 -0500 Subject: [PATCH] internal/gopathwalk: ignore $GOROOT/.../vendor/ in module mode go list in module mode doesn't like looking at vendor directories in GOROOT. Skip them. Change-Id: Iec501fbab70914ea6dd76dcbed97ecda461358d0 Reviewed-on: https://go-review.googlesource.com/c/148159 Run-TryBot: Heschi Kreinick Reviewed-by: Ian Cottrell --- internal/gopathwalk/walk.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/gopathwalk/walk.go b/internal/gopathwalk/walk.go index dc085fc1..a561f9f4 100644 --- a/internal/gopathwalk/walk.go +++ b/internal/gopathwalk/walk.go @@ -11,12 +11,13 @@ import ( "bytes" "fmt" "go/build" - "golang.org/x/tools/internal/fastwalk" "io/ioutil" "log" "os" "path/filepath" "strings" + + "golang.org/x/tools/internal/fastwalk" ) // Options controls the behavior of a Walk call. @@ -176,7 +177,9 @@ func (w *walker) walk(path string, typ os.FileMode) error { if typ == os.ModeDir { base := filepath.Base(path) if base == "" || base[0] == '.' || base[0] == '_' || - base == "testdata" || (!w.opts.ModulesEnabled && base == "node_modules") { + base == "testdata" || + (w.root.Type == RootGOROOT && w.opts.ModulesEnabled && base == "vendor") || + (!w.opts.ModulesEnabled && base == "node_modules") { return filepath.SkipDir } fi, err := os.Lstat(path)