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

Method GetByTraversal

reflectx/reflect.go:44–57  ·  view source on GitHub ↗

GetByTraversal returns a *FieldInfo for a given integer path. It is analogous to reflect.FieldByIndex, but using the cached traversal rather than re-executing the reflect machinery each time.

(index []int)

Source from the content-addressed store, hash-verified

42// analogous to reflect.FieldByIndex, but using the cached traversal
43// rather than re-executing the reflect machinery each time.
44func (f StructMap) GetByTraversal(index []int) *FieldInfo {
45 if len(index) == 0 {
46 return nil
47 }
48
49 tree := f.Tree
50 for _, i := range index {
51 if i >= len(tree.Children) || tree.Children[i] == nil {
52 return nil
53 }
54 tree = tree.Children[i]
55 }
56 return tree
57}
58
59// Mapper is a general purpose mapper of names to struct fields. A Mapper
60// behaves like most marshallers in the standard library, obeying a field tag

Callers 2

TestFieldsEmbeddedFunction · 0.80
TestGetByTraversalFunction · 0.80

Calls

no outgoing calls

Tested by 2

TestFieldsEmbeddedFunction · 0.64
TestGetByTraversalFunction · 0.64