Captain Dero 9687ad9cb4 | 6 years ago | |
---|---|---|
.. | ||
codes | 6 years ago | |
.travis.yml | 6 years ago | |
CHANGELOG.md | 6 years ago | |
LICENSE | 6 years ago | |
Makefile | 6 years ago | |
README.md | 6 years ago | |
appengine.go | 6 years ago | |
bench_test.go | 6 years ago | |
decode.go | 6 years ago | |
decode_map.go | 6 years ago | |
decode_number.go | 6 years ago | |
decode_query.go | 6 years ago | |
decode_slice.go | 6 years ago | |
decode_string.go | 6 years ago | |
decode_value.go | 6 years ago | |
encode.go | 6 years ago | |
encode_map.go | 6 years ago | |
encode_number.go | 6 years ago | |
encode_slice.go | 6 years ago | |
encode_value.go | 6 years ago | |
example_CustomEncoder_test.go | 6 years ago | |
example_registerExt_test.go | 6 years ago | |
example_test.go | 6 years ago | |
ext.go | 6 years ago | |
ext_test.go | 6 years ago | |
msgpack.go | 6 years ago | |
msgpack_test.go | 6 years ago | |
tag.go | 6 years ago | |
time.go | 6 years ago | |
types.go | 6 years ago | |
types_test.go | 6 years ago |
Supports:
msgpack:"my_field_name"
.msgpack:",omitempty"
tag or all empty fields in a struct.API docs: https://godoc.org/github.com/vmihailenco/msgpack. Examples: https://godoc.org/github.com/vmihailenco/msgpack#pkg-examples.
Install:
go get -u github.com/vmihailenco/msgpack
func ExampleMarshal() {
type Item struct {
Foo string
}
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
}
BenchmarkStructVmihailencoMsgpack-4 200000 12814 ns/op 2128 B/op 26 allocs/op
BenchmarkStructUgorjiGoMsgpack-4 100000 17678 ns/op 3616 B/op 70 allocs/op
BenchmarkStructUgorjiGoCodec-4 100000 19053 ns/op 7346 B/op 23 allocs/op
BenchmarkStructJSON-4 20000 69438 ns/op 7864 B/op 26 allocs/op
BenchmarkStructGOB-4 10000 104331 ns/op 14664 B/op 278 allocs/op
Please go through examples to get an idea how to use this package.