diff --git a/go.mod b/go.mod index 5a92fde..520f55d 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,17 @@ module go.unistack.org/micro-codec-msgpack/v3 -go 1.16 +go 1.19 require ( github.com/vmihailenco/msgpack/v5 v5.3.5 + go.unistack.org/micro-proto/v3 v3.3.1 go.unistack.org/micro/v3 v3.10.5 ) + +require ( + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/gnostic v0.6.9 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect + gopkg.in/yaml.v3 v3.0.0 // indirect +) diff --git a/msgpack.go b/msgpack.go index 0f36506..b720c5d 100644 --- a/msgpack.go +++ b/msgpack.go @@ -5,6 +5,7 @@ import ( "io" "github.com/vmihailenco/msgpack/v5" + pb "go.unistack.org/micro-proto/v3/codec" "go.unistack.org/micro/v3/codec" rutil "go.unistack.org/micro/v3/util/reflect" ) @@ -31,7 +32,10 @@ func (c *msgpackCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, err v = nv } - if m, ok := v.(*codec.Frame); ok { + switch m := v.(type) { + case *codec.Frame: + return m.Data, nil + case *pb.Frame: return m.Data, nil } @@ -52,7 +56,11 @@ func (c *msgpackCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) v = nv } - if m, ok := v.(*codec.Frame); ok { + switch m := v.(type) { + case *codec.Frame: + m.Data = b + return nil + case *pb.Frame: m.Data = b return nil }