(field *pb.Field, key string)
| 112 | } |
| 113 | |
| 114 | func getFromMapField(field *pb.Field, key string) (*pb.Field, error) { |
| 115 | fieldMap := field.GetObject() |
| 116 | if fieldMap == nil { |
| 117 | return nil, fmt.Errorf("field '%s' isn't an object, cannot access %s['%s']", field.Key, field.Key, key) |
| 118 | } |
| 119 | |
| 120 | items := fieldMap.GetItems() |
| 121 | if items == nil { |
| 122 | return nil, fmt.Errorf("the object wrapper struct for the value of field '%s' had nil for items, cannot access %s[%s]", field.Key, field.Key, key) |
| 123 | } |
| 124 | |
| 125 | item, ok := items[key] |
| 126 | if !ok { |
| 127 | return nil, fmt.Errorf("no key '%s' in map for field '%s", key, field.Key) |
| 128 | } |
| 129 | return item, nil |
| 130 | } |
| 131 | |
| 132 | // nextField returns the first field in a fieldpath and returns the remainder after removing the root element. |
| 133 | // It will return array as positive number or 0 if refers to array. If there is no next field, an empty string in field will be returned. |
no test coverage detected