mirror of
https://github.com/pyihe/go-pkg.git
synced 2025-09-27 12:22:14 +08:00
28 lines
475 B
Go
28 lines
475 B
Go
package msgpackserialize
|
|
|
|
import (
|
|
"github.com/pyihe/go-pkg/serialize"
|
|
"github.com/vmihailenco/msgpack/v5"
|
|
)
|
|
|
|
const Name = "msgpack"
|
|
|
|
func init() {
|
|
serialize.Register(&msgpackCodec{})
|
|
}
|
|
|
|
type msgpackCodec struct {
|
|
}
|
|
|
|
func (m *msgpackCodec) Name() string {
|
|
return Name
|
|
}
|
|
|
|
func (m *msgpackCodec) Marshal(v interface{}) ([]byte, error) {
|
|
return msgpack.Marshal(v)
|
|
}
|
|
|
|
func (m *msgpackCodec) Unmarshal(data []byte, v interface{}) error {
|
|
return msgpack.Unmarshal(data, v)
|
|
}
|