• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

codes/H24-Aug-2018-

.travis.ymlH A D24-Aug-2018159

CHANGELOG.mdH A D24-Aug-20181.2 KiB

LICENSEH A D24-Aug-20181.3 KiB

MakefileH A D24-Aug-201897

README.mdH A D24-Aug-20182.8 KiB

appengine.goH A D24-Aug-20181.3 KiB

bench_test.goH A D24-Aug-20186.2 KiB

decode.goH A D24-Aug-201810.8 KiB

decode_map.goH A D24-Aug-20186.2 KiB

decode_number.goH A D24-Aug-20185.8 KiB

decode_query.goH A D24-Aug-20182.6 KiB

decode_slice.goH A D24-Aug-20183.4 KiB

decode_string.goH A D24-Aug-20182.9 KiB

decode_value.goH A D24-Aug-20185.7 KiB

encode.goH A D24-Aug-20183.3 KiB

encode_map.goH A D24-Aug-20183.2 KiB

encode_number.goH A D24-Aug-20185.4 KiB

encode_slice.goH A D24-Aug-20182.4 KiB

encode_value.goH A D24-Aug-20184.1 KiB

example_CustomEncoder_test.goH A D24-Aug-2018725

example_registerExt_test.goH A D24-Aug-20181.3 KiB

example_test.goH A D24-Aug-20183.5 KiB

ext.goH A D24-Aug-20184.2 KiB

ext_test.goH A D24-Aug-20183.4 KiB

msgpack.goH A D24-Aug-2018274

msgpack_test.goH A D24-Aug-20185.8 KiB

tag.goH A D24-Aug-2018746

time.goH A D24-Aug-20182.8 KiB

types.goH A D24-Aug-20186.4 KiB

types_test.goH A D24-Aug-201823.9 KiB

README.md

1# MessagePack encoding for Golang
2
3[![Build Status](https://travis-ci.org/vmihailenco/msgpack.svg?branch=v2)](https://travis-ci.org/vmihailenco/msgpack)
4[![GoDoc](https://godoc.org/github.com/vmihailenco/msgpack?status.svg)](https://godoc.org/github.com/vmihailenco/msgpack)
5
6Supports:
7- Primitives, arrays, maps, structs, time.Time and interface{}.
8- Appengine *datastore.Key and datastore.Cursor.
9- [CustomEncoder](https://godoc.org/github.com/vmihailenco/msgpack#example-CustomEncoder)/CustomDecoder interfaces for custom encoding.
10- [Extensions](https://godoc.org/github.com/vmihailenco/msgpack#example-RegisterExt) to encode type information.
11- Renaming fields via `msgpack:"my_field_name"`.
12- Omitting individual empty fields via `msgpack:",omitempty"` tag or all [empty fields in a struct](https://godoc.org/github.com/vmihailenco/msgpack#example-Marshal--OmitEmpty).
13- [Map keys sorting](https://godoc.org/github.com/vmihailenco/msgpack#Encoder.SortMapKeys).
14- Encoding/decoding all [structs as arrays](https://godoc.org/github.com/vmihailenco/msgpack#Encoder.StructAsArray) or [individual structs](https://godoc.org/github.com/vmihailenco/msgpack#example-Marshal--AsArray).
15- [Encoder.UseJSONTag](https://godoc.org/github.com/vmihailenco/msgpack#Encoder.UseJSONTag) with [Decoder.UseJSONTag](https://godoc.org/github.com/vmihailenco/msgpack#Decoder.UseJSONTag) can turn msgpack into drop-in replacement for JSON.
16- Simple but very fast and efficient [queries](https://godoc.org/github.com/vmihailenco/msgpack#example-Decoder-Query).
17
18API docs: https://godoc.org/github.com/vmihailenco/msgpack.
19Examples: https://godoc.org/github.com/vmihailenco/msgpack#pkg-examples.
20
21## Installation
22
23Install:
24
25```shell
26go get -u github.com/vmihailenco/msgpack
27```
28
29## Quickstart
30
31```go
32func ExampleMarshal() {
33	type Item struct {
34		Foo string
35	}
36
37	b, err := msgpack.Marshal(&Item{Foo: "bar"})
38	if err != nil {
39		panic(err)
40	}
41
42	var item Item
43	err = msgpack.Unmarshal(b, &item)
44	if err != nil {
45		panic(err)
46	}
47	fmt.Println(item.Foo)
48	// Output: bar
49}
50```
51
52## Benchmark
53
54```
55BenchmarkStructVmihailencoMsgpack-4   	  200000	     12814 ns/op	    2128 B/op	      26 allocs/op
56BenchmarkStructUgorjiGoMsgpack-4      	  100000	     17678 ns/op	    3616 B/op	      70 allocs/op
57BenchmarkStructUgorjiGoCodec-4        	  100000	     19053 ns/op	    7346 B/op	      23 allocs/op
58BenchmarkStructJSON-4                 	   20000	     69438 ns/op	    7864 B/op	      26 allocs/op
59BenchmarkStructGOB-4                  	   10000	    104331 ns/op	   14664 B/op	     278 allocs/op
60```
61
62## Howto
63
64Please go through [examples](https://godoc.org/github.com/vmihailenco/msgpack#pkg-examples) to get an idea how to use this package.
65
66## See also
67
68- [Golang PostgreSQL ORM](https://github.com/go-pg/pg)
69- [Golang message task queue](https://github.com/go-msgqueue/msgqueue)
70