MCPcopy
hub / github.com/vmihailenco/msgpack / encodeStructValue

Function encodeStructValue

encode_map.go:192–213  ·  view source on GitHub ↗
(e *Encoder, strct reflect.Value)

Source from the content-addressed store, hash-verified

190}
191
192func encodeStructValue(e *Encoder, strct reflect.Value) error {
193 structFields := structs.Fields(strct.Type(), e.structTag)
194 if e.flags&arrayEncodedStructsFlag != 0 || structFields.AsArray {
195 return encodeStructValueAsArray(e, strct, structFields.List)
196 }
197 fields := structFields.OmitEmpty(e, strct)
198
199 if err := e.EncodeMapLen(len(fields)); err != nil {
200 return err
201 }
202
203 for _, f := range fields {
204 if err := e.EncodeString(f.name); err != nil {
205 return err
206 }
207 if err := f.EncodeValue(e, strct); err != nil {
208 return err
209 }
210 }
211
212 return nil
213}
214
215func encodeStructValueAsArray(e *Encoder, strct reflect.Value, fields []*field) error {
216 if err := e.EncodeArrayLen(len(fields)); err != nil {

Callers

nothing calls this directly

Calls 6

encodeStructValueAsArrayFunction · 0.85
FieldsMethod · 0.80
OmitEmptyMethod · 0.80
EncodeMapLenMethod · 0.80
EncodeStringMethod · 0.80
EncodeValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…