Skip to content

Filter Options

Option Detection
FilterSQLC Filename patterns + "Code generated by sqlc" content
FilterTempl _templ.go suffix + templ.Component content
FilterGoEnum _enum.go suffix + "Code generated by go-enum" content
FilterProtobuf .pb.go / _grpc.pb.go suffix + content comment
FilterOapi "oapi-codegen" content marker
FilterDeepcopy zz_generated.* prefix + "Code generated by deepcopy-gen" content
FilterWire wire_gen.go suffix + "Code generated by Wire" content
FilterMoq _moq.go, _moq_test.go suffix + "Code generated by moq" content
FilterMockgen _mock.go suffix + "Code generated by MockGen" content
FilterStringer "Code generated by \"stringer\"" content
FilterMockery mock_ prefix + "Code generated by mockery" content
FilterEnt "Code generated by ent" / "Code generated by entc" content
FilterGqlgen "Code generated by github.com/99designs/gqlgen" content
FilterEasyjson _easyjson.go suffix + "Code generated by easyjson" content
FilterMsgp "Code generated by github.com/tinylib/msgp" content
FilterCounterfeiter fake_ prefix + "Code generated by counterfeiter" content
FilterGoSwagger "Code generated by go-swagger" content
FilterGeneric Any // Code generated by comment (fallback)
FilterAll Enables all of the above
// Filter everything
opts, err := gogenfilter.WithFilterOptions(gogenfilter.FilterAll)
if err != nil {
log.Fatal(err)
}
f, err := gogenfilter.NewFilter(opts)
// Filter specific generators
opts, err = gogenfilter.WithFilterOptions(
gogenfilter.FilterSQLC,
gogenfilter.FilterProtobuf,
gogenfilter.FilterGeneric,
)
if err != nil {
log.Fatal(err)
}
f, err = gogenfilter.NewFilter(opts)

FilterOption values are validated at construction time. Passing an invalid option returns a *FilterConfigError:

// Returns error: "[gogenfilter:invalid_filter_option] invalid filter option \"unknown\""
cfg, err := gogenfilter.WithFilterOptions(gogenfilter.FilterOption("unknown"))
if err != nil {
// handle error
}

List all available options programmatically:

opts := gogenfilter.AllFilterOptions() // []FilterOption
reasons := gogenfilter.AllFilterReasons() // []FilterReason