If your application serializes only primitive types, array, map and struct, code generation is also recommended. You can get the fastest performance with msgpackgen.
- Supported types : primitive / array / slice / struct / map / interface{} and time.Time
- Renaming fields via
msgpack:"field_name"
- Omitting fields via
msgpack:"-"
- Supports extend encoder / decoder
- Can also Encoding / Decoding struct as array
This package requires more than version 1.13
Current version is msgpack/v2.
go get -u github.com/shamaton/msgpack/v2
package main
import (
"github.com/shamaton/msgpack/v2"
)
func main() {
type Struct struct {
String string
}
v := Struct{String: "msgpack"}
d, err := msgpack.Marshal(v)
if err != nil {
panic(err)
}
r := Struct{}
err = msgpack.Unmarshal(d, &r)
if err != nil {
panic(err)
}
}
This result made from shamaton/msgpack_bench
This library is under the MIT License.