MCPcopy
hub / github.com/google/go-cmp / EquateEmpty

Function EquateEmpty

cmp/cmpopts/equate.go:24–26  ·  view source on GitHub ↗

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].

()

Source from the content-addressed store, hash-verified

22//
23// EquateEmpty can be used in conjunction with [SortSlices] and [SortMaps].
24func EquateEmpty() cmp.Option {
25 return cmp.FilterValues(isEmpty, cmp.Comparer(equateAlways))
26}
27
28func isEmpty(x, y interface{}) bool {
29 vx, vy := reflect.ValueOf(x), reflect.ValueOf(y)

Callers 1

TestOptionsFunction · 0.85

Calls 2

FilterValuesFunction · 0.92
ComparerFunction · 0.92

Tested by 1

TestOptionsFunction · 0.68