MCPcopy Index your code
hub / github.com/upper/db / ValidFieldMap

Method ValidFieldMap

internal/reflectx/reflect.go:132–145  ·  view source on GitHub ↗

ValidFieldMap returns the mapper's mapping of field names to reflect valid field values. Panics if v's Kind is not Struct, or v is not Indirectable to a struct kind.

(v reflect.Value)

Source from the content-addressed store, hash-verified

130// field values. Panics if v's Kind is not Struct, or v is not Indirectable to
131// a struct kind.
132func (m *Mapper) ValidFieldMap(v reflect.Value) map[string]reflect.Value {
133 v = reflect.Indirect(v)
134 mustBe(v, reflect.Struct)
135
136 r := map[string]reflect.Value{}
137 tm := m.TypeMap(v.Type())
138 for tagName, fi := range tm.Names {
139 v := ValidFieldByIndexes(v, fi.Index)
140 if v.IsValid() {
141 r[tagName] = v
142 }
143 }
144 return r
145}
146
147// FieldByName returns a field by the its mapped name as a reflect.Value.
148// Panics if v's Kind is not Struct or v is not Indirectable to a struct Kind.

Callers 2

InsertReturningMethod · 0.80
UpdateReturningMethod · 0.80

Calls 3

TypeMapMethod · 0.95
mustBeFunction · 0.85
ValidFieldByIndexesFunction · 0.85

Tested by

no test coverage detected