11# MessagePack encoding for Golang
22
33[ ![ Build Status] ( https://github.com/Basekick-Labs/msgpack/actions/workflows/build.yml/badge.svg?branch=v6 )] ( https://github.com/Basekick-Labs/msgpack/actions/workflows/build.yml )
4- [ ![ PkgGoDev] ( https://pkg.go.dev/badge/github.com/vmihailenco /msgpack/v5 )] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 )
4+ [ ![ PkgGoDev] ( https://pkg.go.dev/badge/github.com/Basekick-Labs /msgpack/v6 )] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 )
55[ ![ Discord] ( https://img.shields.io/badge/discord-chat-5865F2?logo=discord&logoColor=white )] ( https://discord.gg/nxnWfUxsdm )
66
77> A performance-optimized fork of [ vmihailenco/msgpack/v5] ( https://github.com/vmihailenco/msgpack ) ,
88> maintained by [ Basekick Labs] ( https://github.com/Basekick-Labs ) . Built for
99> [ Arc] ( https://github.com/Basekick-Labs/arc ) , a high-performance time-series database.
10- > The upstream module path is preserved for drop-in compatibility.
1110
1211## What's New in v6
1312
14- ** Decode ** — ~ 21% faster, ~ 50% less memory :
15- - Zero-allocation byte-slice reader for ` Unmarshal() `
13+ ** 15 performance optimizations ** — +8.6% throughput in Arc production benchmarks :
14+ - Zero-allocation byte-slice reader for ` Unmarshal() ` ( ~ 21% faster, ~ 50% less memory)
1615- ` *interface{} ` fast path bypasses reflect for the most common decode pattern
16+ - Pooled byte buffer and ` MarshalAppend ` API for zero-alloc encode
17+ - Type-switch fast paths for ` map[string]interface{} ` , ` map[string]string ` , ` []interface{} `
18+ - Two-pass ` OmitEmpty ` , ` isZeroer ` caching, ` reflect.Convert ` skip, sorted key pooling
19+ - ` sync.Pool ` replacement for goroutine-per-type value cache
1720
18- ** Encode** — ~ 12% faster, ~ 43% fewer allocations:
19- - Pooled byte buffer in ` Marshal() ` eliminates per-call ` bytes.Buffer `
20- - Native ` WriteByte ` on the Marshal path removes per-byte heap allocations
21- - Type-switch fast paths for ` map[string]interface{} ` and ` []interface{} `
21+ ** 15 bug fixes** — including OOM protection, float-to-int decoding, non-addressable pointer encode, and more.
2222
23- ** Security:**
24- - OOM protection: slice and map allocations from untrusted input are capped at 1M elements
25-
26- See [ CHANGELOG.md] ( CHANGELOG.md ) for full details.
23+ See [ CHANGELOG.md] ( CHANGELOG.md ) for full details and the [ v6.0.0 release] ( https://github.com/Basekick-Labs/msgpack/releases/tag/v6.0.0 ) .
2724
2825## Resources
2926
3027- [ Discord] ( https://discord.gg/nxnWfUxsdm )
31- - [ Reference] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 )
32- - [ Examples] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #pkg-examples )
28+ - [ Reference] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 )
29+ - [ Examples] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #pkg-examples )
3330
3431## Features
3532
3633- Primitives, arrays, maps, structs, time.Time and interface{}.
3734- Appengine \* datastore.Key and datastore.Cursor.
3835- [ CustomEncoder] /[ CustomDecoder] interfaces for custom encoding.
39- - [ Extensions] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #example-RegisterExt ) to encode
36+ - [ Extensions] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #example-RegisterExt ) to encode
4037 type information.
4138- Renaming fields via ` msgpack:"my_field_name" ` and alias via ` msgpack:"alias:another_name" ` .
4239- Omitting individual empty fields via ` msgpack:",omitempty" ` tag or all
43- [ empty fields in a struct] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #example-Marshal-OmitEmpty ) .
44- - [ Map keys sorting] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #Encoder.SetSortMapKeys ) .
40+ [ empty fields in a struct] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #example-Marshal-OmitEmpty ) .
41+ - [ Map keys sorting] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #Encoder.SetSortMapKeys ) .
4542- Encoding/decoding all
46- [ structs as arrays] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #Encoder.UseArrayEncodedStructs )
43+ [ structs as arrays] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #Encoder.UseArrayEncodedStructs )
4744 or
48- [ individual structs] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #example-Marshal-AsArray ) .
45+ [ individual structs] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #example-Marshal-AsArray ) .
4946- [ Encoder.SetCustomStructTag] with [ Decoder.SetCustomStructTag] can turn msgpack into drop-in
5047 replacement for any tag.
5148- Simple but very fast and efficient
52- [ queries] ( https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #example-Decoder.Query ) .
49+ [ queries] ( https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #example-Decoder.Query ) .
5350
54- [ customencoder ] : https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #CustomEncoder
55- [ customdecoder ] : https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #CustomDecoder
51+ [ customencoder ] : https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #CustomEncoder
52+ [ customdecoder ] : https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #CustomDecoder
5653[ encoder.setcustomstructtag] :
57- https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #Encoder.SetCustomStructTag
54+ https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #Encoder.SetCustomStructTag
5855[ decoder.setcustomstructtag] :
59- https://pkg.go.dev/github.com/vmihailenco /msgpack/v5 #Decoder.SetCustomStructTag
56+ https://pkg.go.dev/github.com/Basekick-Labs /msgpack/v6 #Decoder.SetCustomStructTag
6057
6158## Installation
6259
@@ -67,16 +64,16 @@ msgpack supports 2 last Go versions and requires support for
6764go mod init github.com/my/repo
6865```
6966
70- And then install msgpack (the module path is unchanged from upstream for drop-in compatibility) :
67+ And then install msgpack:
7168
7269``` shell
73- go get github.com/vmihailenco /msgpack/v5
70+ go get github.com/Basekick-Labs /msgpack/v6
7471```
7572
7673## Quickstart
7774
7875``` go
79- import " github.com/vmihailenco /msgpack/v5 "
76+ import " github.com/Basekick-Labs /msgpack/v6 "
8077
8178func ExampleMarshal () {
8279 type Item struct {
0 commit comments