add nil check

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-11-25 12:23:38 +03:00
parent d12d65c191
commit 15804f7fdf

View File

@ -39,6 +39,9 @@ var (
type jsonpbCodec struct{} type jsonpbCodec struct{}
func (c *jsonpbCodec) Marshal(v interface{}) ([]byte, error) { func (c *jsonpbCodec) Marshal(v interface{}) ([]byte, error) {
if v == nil {
return nil, nil
}
switch m := v.(type) { switch m := v.(type) {
case *codec.Frame: case *codec.Frame:
return m.Data, nil return m.Data, nil
@ -52,7 +55,7 @@ func (c *jsonpbCodec) Marshal(v interface{}) ([]byte, error) {
} }
func (c *jsonpbCodec) Unmarshal(d []byte, v interface{}) error { func (c *jsonpbCodec) Unmarshal(d []byte, v interface{}) error {
if d == nil { if d == nil || v == nil {
return nil return nil
} }
switch m := v.(type) { switch m := v.(type) {