Skip to content
3 Stars Free & MIT licensed

Stop linting code no human wrote.

gogenfilter detects files from 18 Go code generators — sqlc, protobuf, templ, and more — so your linters, analyzers, and CI skip them automatically.

New to code generation? Tools like sqlc, protobuf, and templ produce .go files automatically from schemas, proto definitions, and templates. They're valid Go — but no engineer wrote or maintains them.

Get Started →
$ go get github.com/LarsArtmann/gogenfilter/v3
main.go
package main

import (
    "fmt"
    "github.com/LarsArtmann/gogenfilter/v3"
)

func main() {
    opts, err := gogenfilter.WithFilterOptions(gogenfilter.FilterAll)
    if err != nil {
        panic(err)
    }
    f, err := gogenfilter.NewFilter(opts)
    if err != nil {
        panic(err)
    }

    filtered, _ := f.Filter("db/models.go")
    fmt.Println(filtered) // true — sqlc generated
}
How It Works

Built to do one thing well.

No magic, no bloat. Just fast, accurate detection you can drop into any pipeline.

Two-Phase Detection

Filename check first (zero I/O), content scan only when needed.

Functional Options API

Clean, composable configuration. Immutable after construction.

Glob Pattern Matching

Include/exclude with ** glob support via doublestar.

Detailed Results

FilterResult with reason, trace, and path for every file.

SQLC Config Discovery

Parse sqlc.yaml to find output directories automatically.

fs.FS Abstraction

Pluggable filesystem. Test with fstest.MapFS, no real files needed.

Detection

Two-phase detection.

Filename first, content second. Most files are classified without reading a single byte.

P1

Phase 1: Filename

Scan for .pb.go and _templ.go and wire_gen.go

Zero I/O — no file reads
P2

Phase 2: Content

Scan for "Code generated by" and stringer iota markers

Only runs when Phase 1 is inconclusive

Every file classified — zero ambiguity

Before / After

See the difference.

Generated files vanish from your linter output.

Without gogenfilter
$ golangci-lint run
models.pb.go:15: `User` is unused (unused)
db/sqlc_gen.go:8: cyclomatic complexity 38 (gocyclo)
user_templ.go:3: too many statements (funlen)
mock_user_mock.go:5: `MockUser` is unused (unused)
wire_gen.go:12: ineffectual assignment (ineffassign)
5 issues — all on generated files
With gogenfilter
$ golangci-lint run
5 generated files skipped
0 issues from generated code

Add one call to your analyzer. Every generated file disappears from the results.

Illustrative example — file names and issue counts are representative.

Built For

Who is this for?

If you build or run Go tooling that analyzes source code, you need this.

Linters

Skip generated files in static analysis

Code Quality

Exclude generated code from reports

CI / CD

Filter noise from review tooling

Get Started

Three lines. That's the whole API.

Free, MIT-licensed, and ready to drop into your next analyzer.

Trusted by Go tooling

gogenfilter is used by linters, analyzers, and CI pipelines that need to skip generated code. See who depends on it.

View dependents