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
1 changed files with 5 additions and 2 deletions

View File

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