@@ -29,6 +29,9 @@ func (fd *finder) findAllGoFiles(dir string) ([]string, error) {
2929 plog .Debug (fd , "findAllGoFiles" , "dir" , dir )
3030
3131 callback := func (path string , do * godirwalk.Dirent ) error {
32+ if filepath .Base (path ) == "vendor" {
33+ return filepath .SkipDir
34+ }
3235 ext := filepath .Ext (path )
3336 if ext != ".go" {
3437 return nil
@@ -46,18 +49,22 @@ func (fd *finder) findAllGoFiles(dir string) ([]string, error) {
4649}
4750
4851func (fd * finder ) findAllGoFilesImports (dir string ) ([]string , error ) {
52+ return fd .findAllGoFilesImportsIn ("." , dir )
53+ }
54+
55+ func (fd * finder ) findAllGoFilesImportsIn (path , dir string ) ([]string , error ) {
4956 var err error
5057 var names []string
51- oncer .Do (fd .key ("findAllGoFilesImports" , dir ), func () {
58+ oncer .Do (fd .key ("findAllGoFilesImports" , filepath . Join ( dir , path ) ), func () {
5259 ctx := build .Default
5360
5461 if len (ctx .SrcDirs ()) == 0 {
5562 err = errors .New ("no src directories found" )
5663 return
5764 }
5865
59- pkg , err := ctx .ImportDir ( dir , 0 )
60- if strings .HasPrefix (pkg .ImportPath , "github.com/gobuffalo/packr" ) {
66+ pkg , err := ctx .Import ( path , dir , 0 )
67+ if strings .Contains (pkg .ImportPath , "github.com/gobuffalo/packr" ) {
6168 return
6269 }
6370
@@ -79,17 +86,12 @@ func (fd *finder) findAllGoFilesImports(dir string) ([]string, error) {
7986
8087 plog .Debug (fd , "findAllGoFilesImports" , "dir" , dir )
8188
82- names , _ = fd .findAllGoFiles (dir )
89+ names , _ = fd .findAllGoFiles (pkg . Dir )
8390 for _ , n := range pkg .GoFiles {
8491 names = append (names , filepath .Join (pkg .Dir , n ))
8592 }
8693 for _ , imp := range pkg .Imports {
87- if len (ctx .SrcDirs ()) == 0 {
88- continue
89- }
90- d := ctx .SrcDirs ()[len (ctx .SrcDirs ())- 1 ]
91- ip := filepath .Join (d , imp )
92- n , err := fd .findAllGoFilesImports (ip )
94+ n , err := fd .findAllGoFilesImportsIn (imp , dir )
9395 if err != nil && len (n ) != 0 {
9496 names = n
9597 return
0 commit comments