src.dualinventive.com/go/dinet/vendor/gopkg.in/vmihailenco/msgpack.v4
Jerry Jacobs 1193c82181 initial 2024-08-09 12:10:16 +02:00
..
codes initial 2024-08-09 12:10:16 +02:00
.travis.yml initial 2024-08-09 12:10:16 +02:00
CHANGELOG.md initial 2024-08-09 12:10:16 +02:00
LICENSE initial 2024-08-09 12:10:16 +02:00
Makefile initial 2024-08-09 12:10:16 +02:00
README.md initial 2024-08-09 12:10:16 +02:00
appengine.go initial 2024-08-09 12:10:16 +02:00
bench_test.go initial 2024-08-09 12:10:16 +02:00
decode.go initial 2024-08-09 12:10:16 +02:00
decode_map.go initial 2024-08-09 12:10:16 +02:00
decode_number.go initial 2024-08-09 12:10:16 +02:00
decode_query.go initial 2024-08-09 12:10:16 +02:00
decode_slice.go initial 2024-08-09 12:10:16 +02:00
decode_string.go initial 2024-08-09 12:10:16 +02:00
decode_value.go initial 2024-08-09 12:10:16 +02:00
encode.go initial 2024-08-09 12:10:16 +02:00
encode_map.go initial 2024-08-09 12:10:16 +02:00
encode_number.go initial 2024-08-09 12:10:16 +02:00
encode_slice.go initial 2024-08-09 12:10:16 +02:00
encode_value.go initial 2024-08-09 12:10:16 +02:00
example_CustomEncoder_test.go initial 2024-08-09 12:10:16 +02:00
example_registerExt_test.go initial 2024-08-09 12:10:16 +02:00
example_test.go initial 2024-08-09 12:10:16 +02:00
ext.go initial 2024-08-09 12:10:16 +02:00
ext_test.go initial 2024-08-09 12:10:16 +02:00
msgpack.go initial 2024-08-09 12:10:16 +02:00
msgpack_test.go initial 2024-08-09 12:10:16 +02:00
tag.go initial 2024-08-09 12:10:16 +02:00
time.go initial 2024-08-09 12:10:16 +02:00
types.go initial 2024-08-09 12:10:16 +02:00
types_test.go initial 2024-08-09 12:10:16 +02:00

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