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 <heschi@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
864069cfd1
commit
42c3d2e9aa
|
@ -11,12 +11,13 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"golang.org/x/tools/internal/fastwalk"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/tools/internal/fastwalk"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options controls the behavior of a Walk call.
|
// 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 {
|
if typ == os.ModeDir {
|
||||||
base := filepath.Base(path)
|
base := filepath.Base(path)
|
||||||
if base == "" || base[0] == '.' || base[0] == '_' ||
|
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
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
fi, err := os.Lstat(path)
|
fi, err := os.Lstat(path)
|
||||||
|
|
Loading…
Reference in New Issue