Skip to content

Commit

Permalink
[not_panic_proto_codec] 1
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Feb 23, 2021
1 parent a7dcb08 commit 2a66eac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions encoding/proto/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ type codec struct{}
func (codec) Marshal(v interface{}) ([]byte, error) {
vv, ok := v.(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to marshal, message is %T, want proto", v)
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
}
return proto.Marshal(vv)
}

func (codec) Unmarshal(data []byte, v interface{}) error {
vv, ok := v.(proto.Message)
if !ok {
return fmt.Errorf("failed to marshal, message is %T, want proto", v)
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
}
return proto.Unmarshal(data, vv)
}
Expand Down

0 comments on commit 2a66eac

Please sign in to comment.