Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

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

Merged
merged 1 commit into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
21 changes: 21 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down