zapvet
is static analysis tool for zap.
- fieldtype: fieldtype finds confliction type of field
You can get zapvet
by go install
command (Go 1.16 and higher).
$ go install github.com/gostaticanalysis/zapvet@latest
zapvet
run with go vet
as below when Go is 1.12 and higher.
$ go vet -vettool=$(which zapvet) ./...
fieldtype finds confliction type of field.
package a
import "go.uber.org/zap"
func f() {
zap.String("id", "100")
zap.Int("id", 100) // want `"id" conflict type Int vs String`
zap.Any("id", "100") // OK - ignore
zap.Reflect("id", "100") // OK - ignore
zap.String("xxx", "100") // OK
}
You can get analyzers of zapvet from zapvet.Analyzers. And you can use them with unitchecker.