(field *pb.Field, fieldpath string)
| 8 | ) |
| 9 | |
| 10 | func ResolveRelativeField(field *pb.Field, fieldpath string) (resolvedField *pb.Field, err error) { |
| 11 | fieldKey, arrIndex, next := nextField(fieldpath) |
| 12 | if arrIndex >= 0 { |
| 13 | resolvedField, err = getFromArrayField(field, arrIndex) |
| 14 | } else if len(fieldKey) > 0 { |
| 15 | resolvedField, err = getFromMapField(field, fieldKey) |
| 16 | } else { |
| 17 | err = fmt.Errorf("could not resolve fieldpath '%s'", fieldpath) |
| 18 | } |
| 19 | |
| 20 | // return if err or no more fields to traverse (end of field path) |
| 21 | if err != nil || len(next) == 0 { |
| 22 | return |
| 23 | } |
| 24 | return ResolveRelativeField(resolvedField, next) |
| 25 | } |
| 26 | |
| 27 | // FieldValueEquals returns true if the value of the given fields is the same. |
| 28 | func FieldValueEquals(this, other *pb.Field) bool { |
no test coverage detected