Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bottos-project/msgpack-go
message pack library for Bottos blockchain
https://github.com/bottos-project/msgpack-go
bottos bto msgpack
Last synced: 5 days ago
JSON representation
message pack library for Bottos blockchain
- Host: GitHub
- URL: https://github.com/bottos-project/msgpack-go
- Owner: bottos-project
- License: gpl-3.0
- Created: 2018-05-17T04:04:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-15T11:25:19.000Z (over 6 years ago)
- Last Synced: 2024-06-20T03:28:50.756Z (5 months ago)
- Topics: bottos, bto, msgpack
- Language: Go
- Homepage: https://bottos.org
- Size: 30.3 KB
- Stars: 1
- Watchers: 11
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# msgpack
msgpack use a subset of MessagePack protocol, which support types:
```
uint8
uint16
uint32
uint64
str
bin
array
```# encode
```
func Marshal(v interface{}) ([]byte, error)
```Sample code:
```
type TestSubStruct struct{
V1 string
V2 uint32
}type TestStruct struct{
V1 string
V2 uint32
V3 TestSubStruct
}ts := TestStruct {
V1: "testuser",
V2: 99,
V3: TestSubStruct{V1:"123", V2:3},
}
b, err := Marshal(ts)// BytesToHex(b)
// dc0003da00087465737475736572ce00000063dc0002da0003313233ce00000003
```# decode
```
func Unmarshal(data []byte, dst interface{}) error
```Sample code:
```
type TestSubStruct struct{
V1 string
V2 uint32
}type TestStruct struct{
V1 string
V2 uint32
V3 TestSubStruct
}b, err := HexToBytes("dc0003da00087465737475736572ce00000063dc0002da0003313233ce00000003")
ts := TestStruct {}
err = Unmarshal(b, &ts)
fmt.Println("ts", ts)
// ts {testuser 99 {123 3}}
```