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

Method FieldMap

reflectx/reflect.go:117–127  ·  view source on GitHub ↗

FieldMap returns the mapper's mapping of field names to reflect 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

115// FieldMap returns the mapper's mapping of field names to reflect values. Panics
116// if v's Kind is not Struct, or v is not Indirectable to a struct kind.
117func (m *Mapper) FieldMap(v reflect.Value) map[string]reflect.Value {
118 v = reflect.Indirect(v)
119 mustBe(v, reflect.Struct)
120
121 r := map[string]reflect.Value{}
122 tm := m.TypeMap(v.Type())
123 for tagName, fi := range tm.Names {
124 r[tagName] = FieldByIndexes(v, fi.Index)
125 }
126 return r
127}
128
129// FieldByName returns a field by its mapped name as a reflect.Value.
130// Panics if v's Kind is not Struct or v is not Indirectable to a struct Kind.

Callers 1

TestFieldMapFunction · 0.80

Calls 3

TypeMapMethod · 0.95
mustBeFunction · 0.85
FieldByIndexesFunction · 0.85

Tested by 1

TestFieldMapFunction · 0.64