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)
| 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. |
| 117 | func (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. |