MCPcopy
hub / github.com/jmoiron/sqlx / TraversalsByNameFunc

Method TraversalsByNameFunc

reflectx/reflect.go:184–201  ·  view source on GitHub ↗

TraversalsByNameFunc traverses the mapped names and calls fn with the index of each name and the struct traversal represented by that name. Panics if t is not a struct or Indirectable to a struct. Returns the first error returned by fn or nil.

(t reflect.Type, names []string, fn func(int, []int) error)

Source from the content-addressed store, hash-verified

182// each name and the struct traversal represented by that name. Panics if t is not
183// a struct or Indirectable to a struct. Returns the first error returned by fn or nil.
184func (m *Mapper) TraversalsByNameFunc(t reflect.Type, names []string, fn func(int, []int) error) error {
185 t = Deref(t)
186 mustBe(t, reflect.Struct)
187 tm := m.TypeMap(t)
188 for i, name := range names {
189 fi, ok := tm.Names[name]
190 if !ok {
191 if err := fn(i, nil); err != nil {
192 return err
193 }
194 } else {
195 if err := fn(i, fi.Index); err != nil {
196 return err
197 }
198 }
199 }
200 return nil
201}
202
203// FieldByIndexes returns a value for the field given by the struct traversal
204// for the given value.

Callers 3

TraversalsByNameMethod · 0.95
bindArgsFunction · 0.80

Calls 3

TypeMapMethod · 0.95
DerefFunction · 0.85
mustBeFunction · 0.85

Tested by 1