pquerna / ffjson

faster JSON serialization for Go
Apache License 2.0
2.96k stars 235 forks source link

Fix bugs caught by go vet #223

Closed ryboe closed 7 years ago

ryboe commented 7 years ago

These bugs still need to be fixed. I wasn't sure about the correct way to fix them. It looks like a copypasta error in the struct tags, but I'll leave it to you

tests/ff.go:2261: struct field Y repeats json tag "Name" also at tests/ff.go:2260
tests/ff.go:2263: struct field tag `json",omitempty"` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair
tests/ff.go:2264: struct field A repeats json tag "Name" also at tests/ff.go:2260
tests/ff.go:2270: struct field Y repeats json tag "Name" also at tests/ff.go:2269
tests/ff.go:2272: struct field tag `json",omitempty"` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair
tests/ff.go:2273: struct field A repeats json tag "Name" also at tests/ff.go:2269

Here's the rest of the code that go vet doesn't like.

// TDominantField struct
// ffjson: skip
type TDominantField struct {
    X     *int `json:"Name,omitempty"`
    Y     *int `json:"Name,omitempty"`
    Other string
    Name  *int             `json",omitempty"`
    A     *struct{ X int } `json:"Name,omitempty"`
}

// XDominantField struct
type XDominantField struct {
    X     *int `json:"Name,omitempty"`
    Y     *int `json:"Name,omitempty"`
    Other string
    Name  *int             `json",omitempty"`
    A     *struct
}

https://github.com/pquerna/ffjson/tree/master/tests/ff.go#L2259-L2274

If this PR is merged, and the struct tag issue is fixed, we should enable go vet in .travis.yml.

pquerna commented 7 years ago

Thank you for the PR!