MCPcopy
hub / github.com/protocolbuffers/protobuf-go / marshalField

Method marshalField

encoding/prototext/encode.go:202–212  ·  view source on GitHub ↗

marshalField marshals the given field with protoreflect.Value.

(name string, val protoreflect.Value, fd protoreflect.FieldDescriptor)

Source from the content-addressed store, hash-verified

200
201// marshalField marshals the given field with protoreflect.Value.
202func (e encoder) marshalField(name string, val protoreflect.Value, fd protoreflect.FieldDescriptor) error {
203 switch {
204 case fd.IsList():
205 return e.marshalList(name, val.List(), fd)
206 case fd.IsMap():
207 return e.marshalMap(name, val.Map(), fd)
208 default:
209 e.WriteName(name)
210 return e.marshalSingular(val, fd)
211 }
212}
213
214// marshalSingular marshals the given non-repeated field value. This includes
215// all scalar types, enums, messages, and groups.

Callers 1

marshalMessageMethod · 0.95

Calls 8

marshalListMethod · 0.95
marshalMapMethod · 0.95
marshalSingularMethod · 0.95
ListMethod · 0.80
MapMethod · 0.80
IsListMethod · 0.65
IsMapMethod · 0.65
WriteNameMethod · 0.45

Tested by

no test coverage detected