go-kratos--kratos
6cf6f95f58
CodeQL / Analyze (push) Has been cancelled
Sync to Gitee / Run (push) Has been cancelled
Go / build & test (1.25.x) (push) Has been cancelled
Go / build & test (1.26.x) (push) Has been cancelled
Lint / resolve module (push) Has been cancelled
Lint / lint module (push) Has been cancelled
30 行
522 B
Go
30 行
522 B
Go
package msgpack
|
|
|
|
import (
|
|
"github.com/vmihailenco/msgpack/v5"
|
|
|
|
"github.com/go-kratos/kratos/v3/encoding"
|
|
)
|
|
|
|
// Name is the name registered for the msgpack compressor.
|
|
const Name = "msgpack"
|
|
|
|
func init() {
|
|
encoding.RegisterCodec(codec{})
|
|
}
|
|
|
|
// codec is a Codec implementation with msgpack.
|
|
type codec struct{}
|
|
|
|
func (codec) Marshal(v any) ([]byte, error) {
|
|
return msgpack.Marshal(v)
|
|
}
|
|
|
|
func (codec) Unmarshal(data []byte, v any) error {
|
|
return msgpack.Unmarshal(data, v)
|
|
}
|
|
|
|
func (codec) Name() string {
|
|
return Name
|
|
}
|