Describe the bug
I use a validate package https://github.com/gookit/validate in my repo which makes use of the validate struct tag. Today the linter failed on revive claiming the struct tags were invalid. However, they were actually correct.
It's not entirely apparent from the docs page, but the validate rule is actually for the https://pkg.go.dev/github.com/go-playground/validator/v10 package.
In my opinion, this linter is too opinionated to have on by default - validate as a name is very generic and probably used by lots of packages.
To make matters worse, it appears there is no way to disable only the validate struct-tag rule but keep the others.
To Reproduce
Steps to reproduce the behavior:
- Use
golangci-lint with the revive linter enabled
- Create a struct with a validator function that
gookit/validate has that go-playground/validator doesn't. For example:
type Foo struct {
Version int `validate:"gt:0"`
EnableFooBar bool
FooType string `filter:"trim" validate:"in:FOO,BAR,BAZ"`
FooBarName string `filter:"trim" validate:"required_if:enableFooBar,true|max_len:255"`
Name string `filter:"trim" validate:"min_len:1|max_len:256"`
}
Expected behavior
I can think of a few possible options/changes that might make sense:
- Disable this rule by default and have it opt-in (since
go-playground/validator is not part of the standard library)
- Only run these validation rules if
go-playground/validator is found in the go.mod file
- Make the specific
struct-tag rules configurable.
- Currently I can only enable/disable
struct-tag entirely, but I actually would like to use the rules for json, yaml, datastore, etc.
- It would be great if these could be granularly enabled/disabled
- Document on the struct-tag README which package each of the rules is for
Logs
The above example struct Foo will fail with errors like this:
foo.go: struct-tag: unknown option "gt:0" in validate tag (revive)
Version int `validate:"gt:0"`
foo.go: struct-tag: unknown option "required_if:enableFooBar" in validate tag (revive)
FooBarName string `filter:"trim" validate:"required_if:enableFooBar,true|max_len:255"`
^
foo.go: struct-tag: unknown option "min_len:1" in validate tag (revive)
Name string `filter:"trim" validate:"min_len:1|max_len:256"`
foo.go: struct-tag: unknown option "in:FOO" in validate tag (revive)
FooType string `filter:"trim" validate:"in:FOO,BAR,BAZ"`
Desktop (please complete the following information):
- OS: MacOS 15.6.1
- Version of Go: 1.25.0
Additional context
Add any other context about the problem here.
golangci-lint --version
golangci-lint has version 2.4.0 built with go1.25.0
Describe the bug
I use a validate package https://github.com/gookit/validate in my repo which makes use of the
validatestruct tag. Today the linter failed onreviveclaiming the struct tags were invalid. However, they were actually correct.It's not entirely apparent from the docs page, but the validate rule is actually for the https://pkg.go.dev/github.com/go-playground/validator/v10 package.
In my opinion, this linter is too opinionated to have on by default -
validateas a name is very generic and probably used by lots of packages.To make matters worse, it appears there is no way to disable only the
validatestruct-tag rule but keep the others.To Reproduce
Steps to reproduce the behavior:
golangci-lintwith therevivelinter enabledgookit/validatehas thatgo-playground/validatordoesn't. For example:Expected behavior
I can think of a few possible options/changes that might make sense:
go-playground/validatoris not part of the standard library)go-playground/validatoris found in thego.modfilestruct-tagrules configurable.struct-tagentirely, but I actually would like to use the rules forjson,yaml,datastore, etc.Logs
The above example struct
Foowill fail with errors like this:Desktop (please complete the following information):
Additional context
Add any other context about the problem here.