MCPcopy
hub / github.com/golang/protobuf / marshalAppend

Function marshalAppend

proto/wire.go:32–50  ·  view source on GitHub ↗
(buf []byte, m Message, deterministic bool)

Source from the content-addressed store, hash-verified

30var zeroBytes = make([]byte, 0, 0)
31
32func marshalAppend(buf []byte, m Message, deterministic bool) ([]byte, error) {
33 if m == nil {
34 return nil, ErrNil
35 }
36 mi := MessageV2(m)
37 nbuf, err := protoV2.MarshalOptions{
38 Deterministic: deterministic,
39 AllowPartial: true,
40 }.MarshalAppend(buf, mi)
41 if err != nil {
42 return buf, err
43 }
44 if len(buf) == len(nbuf) {
45 if !mi.ProtoReflect().IsValid() {
46 return buf, ErrNil
47 }
48 }
49 return nbuf, checkRequiredNotSet(mi)
50}
51
52// Unmarshal parses a wire-format message in b and places the decoded results in m.
53//

Callers 3

MarshalFunction · 0.85
MarshalMethod · 0.85
EncodeMessageMethod · 0.85

Calls 3

MessageV2Function · 0.85
checkRequiredNotSetFunction · 0.85
ProtoReflectMethod · 0.80

Tested by

no test coverage detected