Is there a way to instruct gofmt (or another tool) to reformat field tags such that the keys are aligned?
For example:
type Example struct {
Field1 string `json:"x" db:"y"`
Field2 int `json:"ababababc" db:"def"`
Field3 string `json:"zyx" db:"egh"`
Field4 string `json:"z" db:"q"`
}
Would be formatted as
type Example struct {
Field1 string `json:"x" db:"y"`
Field2 int `json:"ababababc" db:"def"`
Field3 string `json:"zyx" db:"egh"`
Field4 string `json:"z" db:"q"`
}
(View example in fixed font width please)
Is there a way to instruct go vet (or another tool) to report different field tag key order?
For example:
type Example2 struct {
Field1 string `db:"y" json:"x"`
Field2 int `json:"abc" db:"def"`
}
Would output something along the lines of: "field2: different tag order for json and db"
Thanks.