diff --git a/codec_test.go b/codec_test.go index 3299d4b..d2ed7c2 100644 --- a/codec_test.go +++ b/codec_test.go @@ -14,7 +14,7 @@ func TestRawMessage(t *testing.T) { if err != nil { panic(err) } - t.Logf("%s", buf) + _ = buf } func TestFrame(t *testing.T) { diff --git a/go.mod b/go.mod index 77be795..9113c38 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module go.unistack.org/micro-codec-json/v3 -go 1.19 +go 1.21 + +toolchain go1.23.4 require ( go.unistack.org/micro-proto/v3 v3.4.1 @@ -8,6 +10,6 @@ require ( ) require ( - github.com/google/go-cmp v0.5.9 // indirect - google.golang.org/protobuf v1.34.2 // indirect + github.com/google/go-cmp v0.6.0 // indirect + google.golang.org/protobuf v1.35.2 // indirect ) diff --git a/go.sum b/go.sum index e14a1f1..9a524e8 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= go.unistack.org/micro-proto/v3 v3.4.1 h1:UTjLSRz2YZuaHk9iSlVqqsA50JQNAEK2ZFboGqtEa9Q= go.unistack.org/micro-proto/v3 v3.4.1/go.mod h1:okx/cnOhzuCX0ggl/vToatbCupi0O44diiiLLsZ93Zo= go.unistack.org/micro/v3 v3.10.88 h1:MxlzP+77Y6Kphb3lzHxROL4XfE/WdCQMQpnPv4D9Z8U= go.unistack.org/micro/v3 v3.10.88/go.mod h1:erMgt3Bl7vQQ0e9UpQyR5NlLiZ9pKeEJ9+1tfYFaqUg= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= diff --git a/json.go b/json.go index 5fae8d8..7c29e25 100644 --- a/json.go +++ b/json.go @@ -58,6 +58,10 @@ func (c *jsonCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error) return m.Data, nil case *pb.Frame: return m.Data, nil + case codec.RawMessage: + return []byte(m), nil + case *codec.RawMessage: + return []byte(*m), nil } marshalOptions := DefaultMarshalOptions @@ -107,6 +111,11 @@ func (c *jsonCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) err case *pb.Frame: m.Data = b return nil + case *codec.RawMessage: + *m = append((*m)[0:0], b...) + return nil + case codec.RawMessage: + copy(m, b) } unmarshalOptions := DefaultUnmarshalOptions