@@ -252,18 +252,27 @@ func dirInModule(path, mpath, mdir string, isLocal bool) (dir string, haveGoFile
252
252
// We don't care about build tags, not even "+build ignore".
253
253
// We're just looking for a plausible directory.
254
254
haveGoFiles = haveGoFilesCache .Do (dir , func () interface {} {
255
- f , err := os .Open (dir )
255
+ var pattern string
256
+ if strings .HasSuffix (dir , "/..." ) {
257
+ dir = strings .TrimSuffix (dir , "/..." )
258
+ pattern = filepath .Join (dir , "**" , "*.go" )
259
+ } else {
260
+ pattern = filepath .Join (dir , "*.go" )
261
+ }
262
+ goSourceFiles , err := filepath .Glob (pattern )
256
263
if err != nil {
257
264
return false
258
265
}
259
- defer f .Close ()
260
- names , _ := f .Readdirnames (- 1 )
261
- for _ , name := range names {
262
- if strings .HasSuffix (name , ".go" ) {
263
- info , err := os .Stat (filepath .Join (dir , name ))
264
- if err == nil && info .Mode ().IsRegular () {
265
- return true
266
- }
266
+ // no go source file
267
+ if len (goSourceFiles ) == 0 {
268
+ return false
269
+ }
270
+ // regular file
271
+ for _ , fullPath := range goSourceFiles {
272
+ info , err := os .Stat (fullPath )
273
+ // once one success, we are done
274
+ if err == nil && info .Mode ().IsRegular () {
275
+ return true
267
276
}
268
277
}
269
278
return false
0 commit comments