Don't read unless we have b

This commit is contained in:
Asim Aslam 2019-01-17 12:09:04 +00:00
parent 617db003d4
commit 9ce9977d21

View File

@ -18,13 +18,13 @@ func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
} }
func (c *Codec) ReadBody(b interface{}) error { func (c *Codec) ReadBody(b interface{}) error {
if b == nil {
return nil
}
buf, err := ioutil.ReadAll(c.Conn) buf, err := ioutil.ReadAll(c.Conn)
if err != nil { if err != nil {
return err return err
} }
if b == nil {
return nil
}
return proto.Unmarshal(buf, b.(proto.Message)) return proto.Unmarshal(buf, b.(proto.Message))
} }