EquateEmpty returns a [cmp.Comparer] option that determines all maps and slices with a length of zero to be equal, regardless of whether they are nil. EquateEmpty can be used in conjunction with [SortSlices] and [SortMaps].
()
| 22 | // |
| 23 | // EquateEmpty can be used in conjunction with [SortSlices] and [SortMaps]. |
| 24 | func EquateEmpty() cmp.Option { |
| 25 | return cmp.FilterValues(isEmpty, cmp.Comparer(equateAlways)) |
| 26 | } |
| 27 | |
| 28 | func isEmpty(x, y interface{}) bool { |
| 29 | vx, vy := reflect.ValueOf(x), reflect.ValueOf(y) |