ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.86k stars 295 forks source link

Fix wrong logic in IsCodecEmpty code generation #345

Closed vanackere closed 3 years ago

vanackere commented 3 years ago

For the following types:

type S struct {
    A string
    B string
}

type User struct {
    MaybeEmpty S `json:",omitempty"`
}

The following code was generated:

func (x *S) IsCodecEmpty() bool {
    return !(x.A != "" && x.B != "" && true)
}

Now we generate:

func (x *S) IsCodecEmpty() bool {
    return !(x.A != "" || x.B != "" || false)
}

Should fix https://github.com/ugorji/go/issues/344

ugorji commented 3 years ago

Thanks much. Great catch.