From 0e984b9552d80ef42e4792f0893fab1b5302d4c1 Mon Sep 17 00:00:00 2001 From: rickyshrestha Date: Fri, 28 Jun 2019 15:09:46 +0100 Subject: [PATCH] check file is not a directory when returned as a file (#214) * check file is not a directory when returned as a file * fix PR comments --- v2/jam/parser/finder.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/v2/jam/parser/finder.go b/v2/jam/parser/finder.go index db194dd..76d2621 100644 --- a/v2/jam/parser/finder.go +++ b/v2/jam/parser/finder.go @@ -3,14 +3,15 @@ package parser import ( "fmt" "go/build" + "os" "path/filepath" "strings" "time" - "github.com/gobuffalo/packr/v2/plog" - "github.com/karrick/godirwalk" "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/errx" "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/oncer" + "github.com/gobuffalo/packr/v2/plog" + "github.com/karrick/godirwalk" ) type finder struct { @@ -33,12 +34,22 @@ func (fd *finder) findAllGoFiles(dir string) ([]string, error) { if ext != ".go" { return nil } + //check if path is a dir + fi, err := os.Stat(path) + if err != nil { + return nil + } + + if fi.IsDir() { + return nil + } + names = append(names, path) return nil } err = godirwalk.Walk(dir, &godirwalk.Options{ - FollowSymbolicLinks: true, - Callback: callback, + FollowSymbolicLinks: true, + Callback: callback, }) })