type Equalities … // For convenience, panics on errors func EqualitiesOrDie(funcs ...interface{ … } // AddFuncs is a shortcut for multiple calls to AddFunc. func (e Equalities) AddFuncs(funcs ...interface{ … } // AddFunc uses func as an equality function: it must take // two parameters of the same type, and return a boolean. func (e Equalities) AddFunc(eqFunc interface{ … } type visit … type unexportedTypePanic … func (u unexportedTypePanic) Error() string { … } func (u unexportedTypePanic) String() string { … } func makeUsefulPanic(v reflect.Value) { … } // Tests for deep equality using reflected types. The map argument tracks // comparisons that have already been seen, which allows short circuiting on // recursive types. // equateNilAndEmpty controls whether empty maps/slices are equivalent to nil func (e Equalities) deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, equateNilAndEmpty bool, depth int) bool { … } // DeepEqual is like reflect.DeepEqual, but focused on semantic equality // instead of memory equality. // // It will use e's equality functions if it finds types that match. // // An empty slice *is* equal to a nil slice for our purposes; same for maps. // // Unexported field members cannot be compared and will cause an informative panic; you must add an Equality // function for these types. func (e Equalities) DeepEqual(a1, a2 interface{ … } func (e Equalities) DeepEqualWithNilDifferentFromEmpty(a1, a2 interface{ … } func (e Equalities) deepEqual(a1, a2 interface{ … } func (e Equalities) deepValueDerive(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool { … } // DeepDerivative is similar to DeepEqual except that unset fields in a1 are // ignored (not compared). This allows us to focus on the fields that matter to // the semantic comparison. // // The unset fields include a nil pointer and an empty string. func (e Equalities) DeepDerivative(a1, a2 interface{ … }