msgpack.org[Go] MessagePack encoding for Golang
Latest commit c4fc0fc Oct 23, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
codes Decode time formatted according to RFC3339 into time.Time May 17, 2018
.travis.yml Fix extension decoding for types that don't implement custom marshallers Oct 21, 2018
CHANGELOG.md Preserve type of number during encoding Aug 24, 2018
LICENSE Cleanup license Jun 17, 2017
Makefile Encode error interface as string. Decode string into error interface. F… Nov 14, 2016
README.md readme: mention UseJSONTag Feb 6, 2018
appengine.go Implement time extension May 11, 2017
bench_test.go Preserve type of number during encoding Aug 24, 2018
decode.go Fix extension decoding for types that don't implement custom marshallers Oct 21, 2018
decode_map.go Improve map decoding Aug 24, 2018
decode_number.go Improve doc for DecodeInterface Mar 14, 2018
decode_query.go Improve map decoding Aug 24, 2018
decode_slice.go Improve map decoding Aug 24, 2018
decode_string.go Don't panic if value can't be set Nov 30, 2017
decode_value.go Fix extension decoding for types that don't implement custom marshallers Oct 21, 2018
encode.go Preserve type of number during encoding Aug 24, 2018
encode_map.go Preserve type of number during encoding Aug 24, 2018
encode_number.go Preserve type of number during encoding Aug 24, 2018
encode_slice.go Preserve type of number during encoding Aug 24, 2018
encode_value.go Preserve type of number during encoding Aug 24, 2018
example_CustomEncoder_test.go Preserve type of number during encoding Aug 24, 2018
example_registerExt_test.go Return ptr to the value when decoding into interface Oct 29, 2017
example_test.go Improve example Jan 31, 2018
ext.go Fix extension decoding for types that don't implement custom marshallers Oct 21, 2018
ext_test.go Fix extension decoding for types that don't implement custom marshallers Oct 21, 2018
msgpack.go Remove EncodeSliceLen May 11, 2017
msgpack_test.go Don't panic if value can't be set Nov 30, 2017
tag.go Improve tag parsing Jul 23, 2017
time.go Decode time formatted according to RFC3339 into time.Time May 17, 2018
types.go Allow decoding inlined structs Oct 23, 2018
types_test.go Fix extension decoding for types that don't implement custom marshallers Oct 21, 2018

README.md

MessagePack encoding for Golang

Build Status GoDoc

Supports:

API docs: https://godoc.org/github.com/vmihailenco/msgpack. Examples: https://godoc.org/github.com/vmihailenco/msgpack#pkg-examples.

Installation

Install:

go get -u github.com/vmihailenco/msgpack

Quickstart

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
}

Benchmark

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

Howto

Please go through examples to get an idea how to use this package.

See also