feature(serialize): refactor

This commit is contained in:
pyihe
2022-08-02 10:52:36 +08:00
parent 9c11cf3297
commit f0631c2321
9 changed files with 145 additions and 89 deletions

View 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)
}