https://github.com/shamaton/msgpack
easier, faster, but extendable MessagePack Serializer for Golang. / msgpack.org[Go]
https://github.com/shamaton/msgpack
encoder-decoder go golang messagepack-serializer msgpack serializer
Last synced: 26 days ago
JSON representation
easier, faster, but extendable MessagePack Serializer for Golang. / msgpack.org[Go]
- Host: GitHub
- URL: https://github.com/shamaton/msgpack
- Owner: shamaton
- License: mit
- Created: 2018-08-05T13:58:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-15T13:12:06.000Z (3 months ago)
- Last Synced: 2025-04-12T17:46:03.331Z (about 2 months ago)
- Topics: encoder-decoder, go, golang, messagepack-serializer, msgpack, serializer
- Language: Go
- Homepage:
- Size: 304 KB
- Stars: 156
- Watchers: 5
- Forks: 19
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MessagePack for Golang
[](https://pkg.go.dev/github.com/shamaton/msgpack)

[](https://goreportcard.com/report/github.com/shamaton/msgpack)
[](https://codecov.io/gh/shamaton/msgpack)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fshamaton%2Fmsgpack?ref=badge_shield)## 📣 Notice
If your application serializes only primitive types, array, map and struct, code generation is also recommended.
You can get the fastest performance with [msgpackgen](https://github.com/shamaton/msgpackgen).## Features
* Supported types : primitive / array / slice / struct / map / interface{} and time.Time
* Renaming fields via `msgpack:"field_name"`
* Omitting fields via `msgpack:"-"`
* Supports extend encoder / decoder
* Can also Encoding / Decoding struct as array## Installation
Current version is **msgpack/v2**.
```sh
go get -u github.com/shamaton/msgpack/v2
```## Quick Start
```go
package mainimport (
"github.com/shamaton/msgpack/v2"
"net/http"
)type Struct struct {
String string
}// simple
func main() {
v := Struct{String: "msgpack"}d, err := msgpack.Marshal(v)
if err != nil {
panic(err)
}
r := Struct{}
if err = msgpack.Unmarshal(d, &r); err != nil {
panic(err)
}
}// streaming
func handle(w http.ResponseWriter, r *http.Request) {
var body Struct
if err := msgpack.UnmarshalRead(r, &body); err != nil {
panic(err)
}
if err := msgpack.MarshalWrite(w, body); err != nil {
panic(err)
}
}
```## Benchmark
This result made from [shamaton/msgpack_bench](https://github.com/shamaton/msgpack_bench)
## License
This library is under the MIT License.