Skip to content

Commit 8ae8ca0

Browse files
committed
exclude files too
Signed-off-by: Guillem Bonet <[email protected]>
1 parent 27b27bd commit 8ae8ca0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

parser.go

+6
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,12 @@ func (parser *Parser) getAllGoFileInfo(packageDir, searchDir string) error {
16731673
return err
16741674
}
16751675

1676+
if parser.excludes != nil {
1677+
if _, ok := parser.excludes[relPath]; ok {
1678+
return nil
1679+
}
1680+
}
1681+
16761682
return parser.parseFile(filepath.ToSlash(filepath.Dir(filepath.Clean(filepath.Join(packageDir, relPath)))), path, nil, ParseAll)
16771683
})
16781684
}

parser_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -3772,6 +3772,20 @@ func TestParser_Skip(t *testing.T) {
37723772
assert.Error(t, parser.Skip(filepath.Clean("admin/release"), &mockFS{IsDirectory: true}))
37733773
}
37743774

3775+
func TestParser_ExcludeFilesAndFolders(t *testing.T) {
3776+
t.Parallel()
3777+
3778+
searchDir := "testdata/conflict_name"
3779+
3780+
p := New(SetExcludedDirsAndFiles("api/api1.go,model"))
3781+
err := p.getAllGoFileInfo("testdata", searchDir)
3782+
3783+
assert.NoError(t, err)
3784+
assert.Equal(t, 4, len(p.packages.files))
3785+
3786+
assert.Error(t, p.Skip("model", &mockFS{IsDirectory: true}))
3787+
}
3788+
37753789
func TestGetFieldType(t *testing.T) {
37763790
t.Parallel()
37773791

0 commit comments

Comments
 (0)