codec: fix noop codec

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-12-11 00:32:29 +03:00
parent 0a68a9c278
commit 5c6eba20e7

View File

@ -102,10 +102,10 @@ func (c *noopCodec) Marshal(v interface{}) ([]byte, error) {
} }
func (c *noopCodec) Unmarshal(d []byte, v interface{}) error { func (c *noopCodec) Unmarshal(d []byte, v interface{}) error {
var err error
if v == nil { if v == nil {
return nil return nil
} }
switch ve := v.(type) { switch ve := v.(type) {
case string: case string:
ve = string(d) ve = string(d)
@ -119,6 +119,9 @@ func (c *noopCodec) Unmarshal(d []byte, v interface{}) error {
ve.Data = d ve.Data = d
case *Message: case *Message:
ve.Body = d ve.Body = d
default:
err = ErrInvalidMessage
} }
return ErrInvalidMessage
return err
} }