whyrusleeping / cbor-gen

Codegen for cbor codecs on your types
MIT License
35 stars 25 forks source link

feat: allow unmarshaling of struct with more fields than marshaled struct #50

Closed dirkmc closed 3 years ago

dirkmc commented 3 years ago

It's useful to be able to add a field to a struct and for older versions of the code to ignore the added field when unmarshaling.

// V1
type Animal struct {
  Legs int
}

...

// V2
type Animal struct {
  Legs int
  Eyes int
}

This PR modifies the unmarshaling code such that it will ignore any fields it doesn't recognize.

Stebalien commented 3 years ago

Just making sure: this only applies to maps, right?