Understand the generated interfaces
masterBy default, the code generator implements several interfaces to allow for different serialization patterns:
msgp.Sizer: For determining the size of the encoded data.msgp.Encodableandmsgp.Decodable: Optimized for stream serialization using*msgp.Writerand*msgp.Reader(which are protocol-aware versions of*bufio.Writerand*bufio.Reader).msgp.Marshalerandmsgp.Unmarshaler: Similar tojson.Marshalerandjson.Unmarshaler, typically used for[]byte-oriented operations.
Carefully-designed applications can use these methods to achieve marshalling/unmarshalling with zero heap allocations.