jsonCameler
jsonCameler
can be used to check whether JSON tags of structs are written in lowerCamel case. You can skip lint check by adding comment nocaml
to the fields of structs.
Installation
go install github.com/k3forx/jsonCameler/cmd/jsonCameler@latest
How to use
go vet -vettool=`which jsonCameler` ./...
Here is an example.
package main
import (
"time"
)
type User struct {
ID int `json:"id"` // OK
FirstName string `json:"firstName"` // OK
LastName string `json:"last-name"` // invalid
Username string `json:"user-name"` // nocamel OK
BirthDay time.Time `json:"-"` // OK
}
func main() {
...
}
The result will be like...
go vet -vettool=`which jsonCameler` ./
./main.go:16:2: invalid JSON tag `last-name`