Detection
Combined Detection
Section titled “Combined Detection”DetectReason(filePath, content string, opts ...FilterOption) FilterReason
Section titled “DetectReason(filePath, content string, opts ...FilterOption) FilterReason”Checks if a file is auto-generated based on filename and content. No I/O — you provide the content. Returns the reason or ReasonNotFiltered.
reason := gogenfilter.DetectReason("db/models.go", content, gogenfilter.FilterSQLC, gogenfilter.FilterGeneric,)DetectReasonReader(filePath string, r io.Reader, opts ...FilterOption) (FilterReason, error)
Section titled “DetectReasonReader(filePath string, r io.Reader, opts ...FilterOption) (FilterReason, error)”Same as DetectReason but reads from an io.Reader.
r := bytes.NewBufferString(content)reason, err := gogenfilter.DetectReasonReader("file.go", r, opts...)Per-Generator Detection
Section titled “Per-Generator Detection”Each generator has dedicated Is*Generated(filePath, content string) bool functions:
| Function | Checks |
|---|---|
IsSQLCGenerated | Filename + content markers |
IsTemplGenerated | _templ.go suffix + templ.Component |
IsGoEnumGenerated | _enum.go suffix + content |
IsProtobufGenerated | .pb.go / _grpc.pb.go + content |
IsOapiGenerated | oapi-codegen content marker |
IsDeepcopyGenerated | zz_generated.* + content |
IsWireGenerated | wire_gen.go + content |
IsMoqGenerated | _moq.go + content |
IsMockgenGenerated | _mock.go / mock_ + content |
IsStringerGenerated | Content marker |
IsGenericGenerated | Any Code generated by comment |
Filename Matchers
Section titled “Filename Matchers”Zero-I/O filename checks:
gogenfilter.MatchesSQLCFilename("db/query.sql.go") // trueContent Checkers
Section titled “Content Checkers”gogenfilter.HasSQLCContent(content)gogenfilter.HasSQLCCodePatterns(content)