MCPcopy Create free account
hub / github.com/google/go-cloud / structField

Method structField

docstore/driver/document.go:112–125  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

110}
111
112func (d Document) structField(name string) (reflect.Value, error) {
113 // We do case-insensitive match here to cover the MongoDB's lowercaseFields
114 // option.
115 f := d.fields.MatchFold(name)
116 if f == nil {
117 return reflect.Value{}, gcerr.Newf(gcerr.NotFound, nil, "field %q not found in struct type %s", name, d.s.Type())
118 }
119 fv, ok := fieldByIndex(d.s, f.Index)
120 if !ok {
121 return reflect.Value{}, gcerr.Newf(gcerr.InvalidArgument, nil, "nil embedded pointer; cannot get field %q from %s",
122 name, d.s.Type())
123 }
124 return fv, nil
125}
126
127// Set sets the value of the field path in the document.
128// This creates sub-maps as necessary, if possible.

Callers 2

GetFieldMethod · 0.95
SetFieldMethod · 0.95

Calls 4

NewfFunction · 0.92
fieldByIndexFunction · 0.85
MatchFoldMethod · 0.80
TypeMethod · 0.45

Tested by

no test coverage detected