fix pkger error if a project contains a .go directory #76

This commit is contained in:
Thomas Gosteli 2020-03-04 14:12:00 +01:00
parent c9b56cd758
commit 5d81ba66cb
2 changed files with 26 additions and 2 deletions

View File

@ -108,9 +108,12 @@ func (p *Parser) ParseDir(abs string, mode parser.Mode) ([]*ParsedSource, error)
return nil, fmt.Errorf("%s: here.Parse failed %s", err, abs)
}
fset := token.NewFileSet()
filter := func(f os.FileInfo) bool {
return !f.IsDir()
}
pkgs, err := parser.ParseDir(fset, abs, nil, 0)
fset := token.NewFileSet()
pkgs, err := parser.ParseDir(fset, abs, filter, 0)
if err != nil {
return nil, fmt.Errorf("%s: ParseDir failed %s", err, abs)
}

View File

@ -71,6 +71,27 @@ func Test_Parser_Ref_Include(t *testing.T) {
r.Equal(26, l)
}
func Test_Parser_dotGo_Directory(t *testing.T) {
r := require.New(t)
ref, err := pkgtest.NewRef()
r.NoError(err)
defer os.RemoveAll(ref.Dir)
err = os.Mkdir(filepath.Join(ref.Dir, ".go"), 0755)
r.NoError(err)
disk, err := stdos.New(ref.Info)
r.NoError(err)
_, err = pkgtest.LoadFiles("/", ref, disk)
r.NoError(err)
res, err := Parse(ref.Info)
r.NoError(err)
r.Equal(11, len(res))
}
func Test_Parser_Example_HTTP(t *testing.T) {
r := require.New(t)