Closed klauspost closed 4 days ago
Example:
type S struct { ABool bool `msg:",omitempty"` }
... would ignore the omitempty, since all tags were replaced, resulting in output like:
omitempty
// MarshalMsg implements msgp.Marshaler func (z S) MarshalMsg(b []byte) (o []byte, err error) { o = msgp.Require(b, z.Msgsize()) // map header, size 1 // string "ABool" o = append(o, 0x81, 0xa5, 0x41, 0x42, 0x6f, 0x6f, 0x6c) o = msgp.AppendBool(o, z.ABool) return }
Keep remaining tags when filling out the field name.
Code after:
// MarshalMsg implements msgp.Marshaler func (z S) MarshalMsg(b []byte) (o []byte, err error) { o = msgp.Require(b, z.Msgsize()) // check for omitted fields zb0001Len := uint32(1) var zb0001Mask uint8 /* 1 bits */ _ = zb0001Mask if z.ABool == false { zb0001Len-- zb0001Mask |= 0x1 } // variable map header, size zb0001Len o = append(o, 0x80|uint8(zb0001Len)) if zb0001Len == 0 { return } if (zb0001Mask & 0x1) == 0 { // if not omitted // string "ABool" o = append(o, 0xa5, 0x41, 0x42, 0x6f, 0x6f, 0x6c) o = msgp.AppendBool(o, z.ABool) } return }
Regression test added.
Example:
... would ignore the
omitempty
, since all tags were replaced, resulting in output like:Keep remaining tags when filling out the field name.
Code after:
Regression test added.