mirror of
https://github.com/golang/go
synced 2024-11-17 22:14:43 -07:00
cmd: ignore the directory named go.mod
The existing implementation does not check in all cases whether go.mod is a regular file. Fixes #30788
This commit is contained in:
parent
1024b25d0c
commit
871f35980e
@ -233,8 +233,8 @@ func dirInModule(path, mpath, mdir string, isLocal bool) (dir string, haveGoFile
|
||||
if isLocal {
|
||||
for d := dir; d != mdir && len(d) > len(mdir); {
|
||||
haveGoMod := haveGoModCache.Do(d, func() interface{} {
|
||||
_, err := os.Stat(filepath.Join(d, "go.mod"))
|
||||
return err == nil
|
||||
fi, err := os.Stat(filepath.Join(d, "go.mod"))
|
||||
return err == nil && !fi.IsDir()
|
||||
}).(bool)
|
||||
|
||||
if haveGoMod {
|
||||
|
@ -76,7 +76,7 @@ func matchPackages(pattern string, tags map[string]bool, useStd bool, modules []
|
||||
}
|
||||
// Stop at module boundaries.
|
||||
if path != root {
|
||||
if _, err := os.Stat(filepath.Join(path, "go.mod")); err == nil {
|
||||
if fi, err := os.Stat(filepath.Join(path, "go.mod")); err == nil && !fi.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ func MatchPackagesInFS(pattern string) *Match {
|
||||
|
||||
if !top && cfg.ModulesEnabled {
|
||||
// Ignore other modules found in subdirectories.
|
||||
if _, err := os.Stat(filepath.Join(path, "go.mod")); err == nil {
|
||||
if fi, err := os.Stat(filepath.Join(path, "go.mod")); err == nil && !fi.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user