Announcing go-msgpack, a rich msgpack codec for Go. Supports encoding/decoding to msgpack binary format, and use for net/rpc communication.
https://github.com/ugorji/go-msgpack
http://gopkgdoc.appspot.com/pkg/github.com/ugorji/go-msgpack
It provides features similar to encoding packages in the standard library (ie json, xml, gob, etc).
Supports:
Usage:
// v can be interface{}, int32, bool, map[string]bool, etc
dec = msgpack.NewDecoder(r, nil)
err = dec.Decode(&v)
enc = msgpack.NewEncoder(w, nil)
err = enc.Encode(v)
//methods below are convenience methods over functions above.
data, err = msgpack.Marshal(v, nil)
err = msgpack.Unmarshal(data, &v, nil)
//RPC Communication
conn, err = net.Dial("tcp", "localhost:5555")
rpcCodec := msgpack.NewRPCCodec(conn)
client := rpc.NewClientWithCodec(rpcCodec)
...
Why?
I was initially looking at different binary serialization formats for an application I’m developing. I looked at Thrift, Protocol Buffers, BSON, Msgpack, etc.
I finally decided on msgpack:
Unfortunately, the Go library on the msgpack.org site is old, does not build, and is not “smart” like the encoding/json package. Specifically, it doesn’t allow me decode into a typed object (e.g. struct, bool, etc).
I wrote go-msgpack to give the same conveniences we’ve gotten used to (spoiled by using the encoding/json package), while being really performant.
Summary of my testing:
Hope folks use it and enjoy using it. I know I will. Please feel free to send me feedback.