ugorji / go

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

codecgen fails on a file #351

Closed jba closed 3 years ago

jba commented 3 years ago

When I run codecgen on the following file I get the output ???? !!!! We shouldn't get to this point !!!! ???????? !!!! We shouldn't get to this point !!!! ????.

package data

import (
    "crypto/sha256"

    "github.com/google/licensecheck"
)

type LicenseContents struct {
    Contents     []byte
    ContentsHash [sha256.Size]byte     // SHA256 of the contents, to dedup equal contents                                                                                                                                                     
    OldTypes     []string              // from the DB, stored in the gob file                                                                                                                                                                 
    OldCoverage  licensecheck.Coverage // ditto                                                                                                                                                                                               
    NewTypes     []string              // not populated from the gob                                                                                                                                                                          
    NewCoverage  licensecheck.Coverage // ditto                                                                                                                                                                                               
}
ugorji commented 3 years ago

Oops - sorry about that. That was some leftover debugging output, while I was implementing a less intrusive empty check. I will remove it now. Things should work ok.

See https://github.com/ugorji/go/blob/master/codec/gen.go#L1076

We tried to see if we can compare directly to a zero value. But since you have slices, then the type is not comparable and we cannot compare to the zero value of the struct, so we have to compare field by field (which we do).

Ignore the output for now, and I will fix it in a subsequent update later this week (likely tomorrow).