MCPcopy
hub / github.com/gogo/protobuf / EncodeMessage

Method EncodeMessage

proto/encode.go:190–196  ·  view source on GitHub ↗

EncodeMessage writes the protocol buffer to the Buffer, prefixed by a varint-encoded length.

(pb Message)

Source from the content-addressed store, hash-verified

188// EncodeMessage writes the protocol buffer to the Buffer,
189// prefixed by a varint-encoded length.
190func (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.
199func isNil(v reflect.Value) bool {

Callers 2

TestEncodeDecodeFunction · 0.95
encodeMessageCheckFunction · 0.80

Calls 5

growMethod · 0.95
EncodeVarintMethod · 0.95
MarshalMethod · 0.95
SizeFunction · 0.85
SizeVarintFunction · 0.85

Tested by 2

TestEncodeDecodeFunction · 0.76
encodeMessageCheckFunction · 0.64