TraversalsByName returns a slice of int slices which represent the struct traversals for each mapped name. Panics if t is not a struct or Indirectable to a struct. Returns empty int slice for each name not found.
(t reflect.Type, names []string)
| 165 | // traversals for each mapped name. Panics if t is not a struct or Indirectable |
| 166 | // to a struct. Returns empty int slice for each name not found. |
| 167 | func (m *Mapper) TraversalsByName(t reflect.Type, names []string) [][]int { |
| 168 | r := make([][]int, 0, len(names)) |
| 169 | m.TraversalsByNameFunc(t, names, func(_ int, i []int) error { |
| 170 | if i == nil { |
| 171 | r = append(r, []int{}) |
| 172 | } else { |
| 173 | r = append(r, i) |
| 174 | } |
| 175 | |
| 176 | return nil |
| 177 | }) |
| 178 | return r |
| 179 | } |
| 180 | |
| 181 | // TraversalsByNameFunc traverses the mapped names and calls fn with the index of |
| 182 | // each name and the struct traversal represented by that name. Panics if t is not |