build(deps): bump github.com/shamaton/msgpack/v2 from 2.1.1 to 2.2.0
Bumps [github.com/shamaton/msgpack/v2](https://github.com/shamaton/msgpack) from 2.1.1 to 2.2.0. - [Release notes](https://github.com/shamaton/msgpack/releases) - [Commits](https://github.com/shamaton/msgpack/compare/v2.1.1...v2.2.0) --- updated-dependencies: - dependency-name: github.com/shamaton/msgpack/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
09fad45811
commit
c2c740592d
+18
-7
@@ -17,8 +17,6 @@ You can get the fastest performance with [msgpackgen](https://github.com/shamato
|
||||
* Supports extend encoder / decoder
|
||||
* Can also Encoding / Decoding struct as array
|
||||
|
||||
This package requires more than version **1.13**
|
||||
|
||||
## Installation
|
||||
|
||||
Current version is **msgpack/v2**.
|
||||
@@ -32,12 +30,15 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/shamaton/msgpack/v2"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Struct struct {
|
||||
String string
|
||||
}
|
||||
|
||||
// simple
|
||||
func main() {
|
||||
type Struct struct {
|
||||
String string
|
||||
}
|
||||
v := Struct{String: "msgpack"}
|
||||
|
||||
d, err := msgpack.Marshal(v)
|
||||
@@ -45,11 +46,21 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
r := Struct{}
|
||||
err = msgpack.Unmarshal(d, &r)
|
||||
if err != nil {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user