go-codec: Primer and How To Guide
go-codec is a high performance and feature rich library that provides idiomatic encoding and decoding support for msgpack, binc, cbor, json and simple formats. It supports both runtime introspection (reflection) and code generation. Below, we will walk you through using it for your serialization needs.
Code Generation using go-codec - for 2-20X performance improvement
go-codec supports compile-time generation of encoders and decoders for named types, which does not incur the overhead of reflection in the typical case, giving 2X-20X performance improvement over the idiomatic runtime introspection mode.
Idiomatic encoding and decoding types within go typically relies on the reflection capabilities of the go runtime. This affords flexible performance without the need for a pre-compilation step; the go types contain all the information needed and the runtime exposes the full types via reflection. However, introspecting the runtime to get this information has a noticeable overhead, which can be eliminated by a pre-compilation/code-generation step.