https://github.com/ferhatelmas/msgpack-go
Backup since original repo is gone
https://github.com/ferhatelmas/msgpack-go
Last synced: 2 months ago
JSON representation
Backup since original repo is gone
- Host: GitHub
- URL: https://github.com/ferhatelmas/msgpack-go
- Owner: ferhatelmas
- Created: 2015-05-29T10:02:31.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-29T10:03:06.000Z (almost 10 years ago)
- Last Synced: 2025-01-24T12:13:45.009Z (4 months ago)
- Language: Go
- Size: 105 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# encoding/msgpack
MessagePack encoding package for Go
## Usage
### Pack/Unpack
packed, _ := msgpack.Marshal([]interface{}{1, nil, "three"})var unpacked interface{}
msgpack.Unmarshal(packed, &unpacked)### Streaming
enc := msgpack.NewEncoder(os.Stdout)enc.Encode(true)
enc.Encode(false)
enc.Encode([]int{1, 2, 3})dec := msgpack.NewDecoder(os.Stdin)
for {
var data interface{}
if dec.Decode(&data) != nil {
break
}fmt.Println(data)
}### Struct
type Person struct {
Name string `msgpack:"name"`
Age uint8 `msgpack:"age"`
}var unpacked Person
packed, _ := msgpack.Marshal(Person{"hinasssan", 16})
msgpack.Unmarshal(packed, &unpacked)
fmt.Println(unpacked.Name)