Pattern Matching
Wildcards
Section titled “Wildcards”Include and exclude patterns support two wildcards:
| Pattern | Meaning |
|---|---|
* | Matches any sequence of non-separator characters (single path segment) |
** | Matches zero or more complete path segments (crosses / boundaries) |
Include Patterns
Section titled “Include Patterns”Include patterns restrict scope: only files matching at least one include pattern are checked. All other files are immediately filtered (skipped).
f := gogenfilter.NewFilter( gogenfilter.Enabled(), gogenfilter.WithFilterOptions(gogenfilter.FilterAll), gogenfilter.WithIncludePatterns("pkg/**"),)Files outside pkg/ are filtered with ReasonIncludePattern.
Exclude Patterns
Section titled “Exclude Patterns”Exclude patterns broaden scope: matching files are always filtered, regardless of detection.
f := gogenfilter.NewFilter( gogenfilter.Enabled(), gogenfilter.WithFilterOptions(gogenfilter.FilterAll), gogenfilter.WithExcludePatterns("**/*.pb.go", "mocks/*"),)Pattern Rules
Section titled “Pattern Rules”- Patterns without
/match against the filename only:*.pb.gomatchesany/path/user.pb.go - Patterns with
/match against the full path:internal/*.gomatchesinternal/handler.go **/at the start matches at any depth:\*_/mocks/_.gomatchespkg/mocks/service.go/**at the end matches anything under a directory:generated/\*\*matchesgenerated/a/b/c.go/**/in the middle bridges any number of segments:src/\*\*/test.gomatchessrc/pkg/test.go
Combined Example
Section titled “Combined Example”f := gogenfilter.NewFilter( gogenfilter.Enabled(), gogenfilter.WithFilterOptions(gogenfilter.FilterAll), gogenfilter.WithIncludePatterns("pkg/**"), gogenfilter.WithExcludePatterns("**/*.pb.go"),)This filters everything inside pkg/ except protobuf files, which are excluded regardless.