cmp/cmpopts/ignore.go
func IgnoreMapEntries(discardFunc interface{}) cmp.Option {
	vf := reflect.ValueOf(discardFunc)
	if !function.IsType(vf.Type(), function.KeyValuePredicate) || vf.IsNil() {
		panic(fmt.Sprintf("invalid discard function: %T", discardFunc))
	}
	return cmp.FilterPath(func(p cmp.Path) bool {
		mi, ok := p.Index(-1).(cmp.MapIndex)
		if !ok {
			return false
		}
		if !mi.Key().Type().AssignableTo(vf.Type().In(0)) || !mi.Type().AssignableTo(vf.Type().In(1)) {
			return false
		}
		k := mi.Key()
		vx, vy := mi.Values()
		if vx.IsValid() && vf.Call([]reflect.Value{k, vx})[0].Bool() {
			return true
		}
		if vy.IsValid() && vf.Call([]reflect.Value{k, vy})[0].Bool() {
			return true
		}
		return false
	}, cmp.Ignore())
}
func IgnoreMapEntries(discardFunc interface{}) cmp.Option {
	vf := reflect.ValueOf(discardFunc)
	if !function.IsType(vf.Type(), function.KeyValuePredicate) || vf.IsNil() {
		panic(fmt.Sprintf("invalid discard function: %T", discardFunc))
	}
	return cmp.FilterPath(func(p cmp.Path) bool {
		mi, ok := p.Index(-1).(cmp.MapIndex)
		if !ok {
			return false
		}
		if !mi.Key().Type().AssignableTo(vf.Type().In(0)) || !mi.Type().AssignableTo(vf.Type().In(1)) {
			return false
		}
		k := mi.Key()
		vx, vy := mi.Values()
		if vx.IsValid() && vf.Call([]reflect.Value{k, vx})[0].Bool() {
			return true
		}
		if vy.IsValid() && vf.Call([]reflect.Value{k, vy})[0].Bool() {
			return true
		}
		return false
	}, cmp.Ignore())
}
func IgnoreMapEntries ( discardFunc interface { } ) cmp . Option { vf := reflect . ValueOf ( discardFunc ) if ! function . IsType ( vf . Type ( ) , function . KeyValuePredicate ) || vf . IsNil ( ) { panic ( fmt . Sprintf ( " " , discardFunc ) ) } return cmp . FilterPath ( func ( p cmp . Path ) bool { mi , ok := p . Index ( - 1 ) . ( cmp . MapIndex ) if ! ok { return false } if ! mi . Key ( ) . Type ( ) . AssignableTo ( vf . Type ( ) . In ( 0 ) ) || ! mi . Type ( ) . AssignableTo ( vf . Type ( ) . In ( 1 ) ) { return false } k := mi . Key ( ) vx , vy := mi . Values ( ) if vx . IsValid ( ) && vf . Call ( [ ] reflect . Value { k , vx } ) [ 0 ] . Bool ( ) { return true } if vy . IsValid ( ) && vf . Call ( [ ] reflect . Value { k , vy } ) [ 0 ] . Bool ( ) { return true } return false } , cmp . Ignore ( ) ) }
// IgnoreMapEntries returns an Option that ignores entries of map[K]V.
// The discard function must be of the form "func(T, R) bool" which is used to
// ignore map entries of type K and V, where K and V are assignable to T and R.
// Entries are ignored if the function reports true.
IgnoreMapEntries returns an Option that ignores entries of map [ K ] V . The discard function must be of the form func ( T R ) bool which is used to ignore map entries of type K and V where K and V are assignable to T and R . Entries are ignored if the function reports true .