MCPcopy
hub / github.com/expr-lang/expr / fieldByIndex

Function fieldByIndex

vm/runtime/runtime.go:128–144  ·  view source on GitHub ↗
(v reflect.Value, field *Field)

Source from the content-addressed store, hash-verified

126}
127
128func fieldByIndex(v reflect.Value, field *Field) reflect.Value {
129 if len(field.Index) == 1 {
130 return v.Field(field.Index[0])
131 }
132 for i, x := range field.Index {
133 if i > 0 {
134 if v.Kind() == reflect.Ptr {
135 if v.IsNil() {
136 panic(fmt.Sprintf("cannot get %v from %v", field.Path[i], field.Path[i-1]))
137 }
138 v = v.Elem()
139 }
140 }
141 v = v.Field(x)
142 }
143 return v
144}
145
146type Method struct {
147 Index int

Callers 1

FetchFieldFunction · 0.85

Calls 2

SprintfMethod · 0.80
ElemMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…