优化rpc返回参数与请求参数不一致时报错

This commit is contained in:
duanhf2012
2023-03-06 11:47:23 +08:00
parent d3ad7fc898
commit 47dc21aee1
2 changed files with 14 additions and 12 deletions

View File

@@ -41,7 +41,10 @@ func (slf *GoGoPBProcessor) Marshal(v interface{}) ([]byte, error){
}
func (slf *GoGoPBProcessor) Unmarshal(data []byte, msg interface{}) error{
protoMsg := msg.(proto.Message)
protoMsg,ok := msg.(proto.Message)
if ok == false {
return fmt.Errorf("%+v is not of proto.Message type",msg)
}
return proto.Unmarshal(data, protoMsg)
}