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

..03-May-2022-

codes/H12-Jun-2020-9170

.golangci.ymlH A D12-Jun-2020164 1312

.travis.ymlH A D12-Jun-2020338 2216

CHANGELOG.mdH A D12-Jun-20201.2 KiB2517

LICENSEH A D12-Jun-20201.3 KiB2622

MakefileH A D12-Jun-2020152 76

README.mdH A D12-Jun-20203 KiB7355

appengine.goH A D12-Jun-20201.3 KiB6553

bench_test.goH A D12-Jun-20206.8 KiB376314

decode.goH A D12-Jun-202012.5 KiB618511

decode_map.goH A D12-Jun-20206.4 KiB351293

decode_number.goH A D12-Jun-20205.8 KiB308269

decode_query.goH A D12-Jun-20202.6 KiB159132

decode_slice.goH A D12-Jun-20203.4 KiB192160

decode_string.goH A D12-Jun-20203 KiB187158

decode_value.goH A D12-Jun-20206 KiB277236

encode.goH A D12-Jun-20204.5 KiB242184

encode_map.goH A D12-Jun-20203.2 KiB173143

encode_number.goH A D12-Jun-20206 KiB245192

encode_slice.goH A D12-Jun-20202.6 KiB132113

encode_value.goH A D12-Jun-20205.1 KiB217185

example_CustomEncoder_test.goH A D12-Jun-2020728 3929

example_registerExt_test.goH A D12-Jun-20201.3 KiB6348

example_test.goH A D12-Jun-20203.5 KiB198154

ext.goH A D12-Jun-20204.7 KiB245203

ext_test.goH A D12-Jun-20204.3 KiB236193

go.modH A D12-Jun-2020382 1411

go.sumH A D12-Jun-20202.1 KiB2524

intern.goH A D12-Jun-20204.6 KiB237199

msgpack.goH A D12-Jun-2020274 1813

msgpack_test.goH A D12-Jun-20206.1 KiB288231

safe.goH A D12-Jun-2020251 147

time.goH A D12-Jun-20202.9 KiB150122

types.goH A D12-Jun-20207.9 KiB383313

types_test.goH A D12-Jun-202025.2 KiB1,102932

unsafe.goH A D12-Jun-2020390 2315

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"` and alias via `msgpack:"alias:another_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.UseArrayForStructs) 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
23This project uses [Go Modules](https://github.com/golang/go/wiki/Modules) and semantic import versioning since v4:
24
25``` shell
26go mod init github.com/my/repo
27go get github.com/vmihailenco/msgpack/v4
28```
29
30## Quickstart
31
32``` go
33import "github.com/vmihailenco/msgpack/v4"
34
35func ExampleMarshal() {
36	type Item struct {
37		Foo string
38	}
39
40	b, err := msgpack.Marshal(&Item{Foo: "bar"})
41	if err != nil {
42		panic(err)
43	}
44
45	var item Item
46	err = msgpack.Unmarshal(b, &item)
47	if err != nil {
48		panic(err)
49	}
50	fmt.Println(item.Foo)
51	// Output: bar
52}
53```
54
55## Benchmark
56
57```
58BenchmarkStructVmihailencoMsgpack-4   	  200000	     12814 ns/op	    2128 B/op	      26 allocs/op
59BenchmarkStructUgorjiGoMsgpack-4      	  100000	     17678 ns/op	    3616 B/op	      70 allocs/op
60BenchmarkStructUgorjiGoCodec-4        	  100000	     19053 ns/op	    7346 B/op	      23 allocs/op
61BenchmarkStructJSON-4                 	   20000	     69438 ns/op	    7864 B/op	      26 allocs/op
62BenchmarkStructGOB-4                  	   10000	    104331 ns/op	   14664 B/op	     278 allocs/op
63```
64
65## Howto
66
67Please go through [examples](https://godoc.org/github.com/vmihailenco/msgpack#pkg-examples) to get an idea how to use this package.
68
69## See also
70
71- [Golang PostgreSQL ORM](https://github.com/go-pg/pg)
72- [Golang message task queue](https://github.com/vmihailenco/taskq)
73