Skip to content

Commit

Permalink
exclude files too
Browse files Browse the repository at this point in the history
Signed-off-by: Guillem Bonet <[email protected]>
  • Loading branch information
Guillembonet committed Jul 28, 2023
1 parent 27b27bd commit 8ae8ca0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,12 @@ func (parser *Parser) getAllGoFileInfo(packageDir, searchDir string) error {
return err
}

if parser.excludes != nil {
if _, ok := parser.excludes[relPath]; ok {
return nil
}
}

return parser.parseFile(filepath.ToSlash(filepath.Dir(filepath.Clean(filepath.Join(packageDir, relPath)))), path, nil, ParseAll)
})
}
Expand Down
14 changes: 14 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3772,6 +3772,20 @@ func TestParser_Skip(t *testing.T) {
assert.Error(t, parser.Skip(filepath.Clean("admin/release"), &mockFS{IsDirectory: true}))
}

func TestParser_ExcludeFilesAndFolders(t *testing.T) {
t.Parallel()

searchDir := "testdata/conflict_name"

p := New(SetExcludedDirsAndFiles("api/api1.go,model"))
err := p.getAllGoFileInfo("testdata", searchDir)

assert.NoError(t, err)
assert.Equal(t, 4, len(p.packages.files))

assert.Error(t, p.Skip("model", &mockFS{IsDirectory: true}))
}

func TestGetFieldType(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 8ae8ca0

Please sign in to comment.