EncodeMessage writes the protocol buffer to the Buffer, prefixed by a varint-encoded length.
(pb Message)
| 188 | // EncodeMessage writes the protocol buffer to the Buffer, |
| 189 | // prefixed by a varint-encoded length. |
| 190 | func (p *Buffer) EncodeMessage(pb Message) error { |
| 191 | siz := Size(pb) |
| 192 | sizVar := SizeVarint(uint64(siz)) |
| 193 | p.grow(siz + sizVar) |
| 194 | p.EncodeVarint(uint64(siz)) |
| 195 | return p.Marshal(pb) |
| 196 | } |
| 197 | |
| 198 | // All protocol buffer fields are nillable, but be careful. |
| 199 | func isNil(v reflect.Value) bool { |