MessagePack
MessagePack encoding for Go
Efficient
msgpack is a drop-in replacement for encoding/json package that can be up to 5 times faster.
Customizable
Use custom encoders and decoders to customize serialization for user-defined and stdlib types.
Extensible
Extend MessagePack by providing type-aware encoding for your types using ext format family.
import "github.com/vmihailenco/msgpack/v5"
type Item struct {
Foo string
}
func main() {
b, err := msgpack.Marshal(&Item{Foo: "bar"})
if err != nil {
panic(err)
}
var item Item
err = msgpack.Unmarshal(b, &item)
if err != nil {
panic(err)
}
fmt.Println(item.Foo)
// Output: bar
}