mirror of
https://github.com/pyihe/go-pkg.git
synced 2025-10-21 15:09:29 +08:00
feature(serialize): refactor
This commit is contained in:
27
serialize/msgpack/msgpack.go
Normal file
27
serialize/msgpack/msgpack.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package msgpack
|
||||
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user