diff --git a/parser/parser.go b/parser/parser.go index 2ee1f9a..f16c6ef 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -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) } diff --git a/parser/parser_test.go b/parser/parser_test.go index 0f9f22d..7563456 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -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)