Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
f6d61d4cc8
commit
aaedc8569a
@ -14,7 +14,7 @@ func TestRawMessage(t *testing.T) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
t.Logf("%s", buf)
|
||||
_ = buf
|
||||
}
|
||||
|
||||
func TestFrame(t *testing.T) {
|
||||
|
8
go.mod
8
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
|
||||
)
|
||||
|
6
go.sum
6
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=
|
||||
|
9
json.go
9
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user