7 // DeepEqual returns if the two values are deeply equal like reflect.DeepEqual.
8 // In addition to this, this method will also dereference the input values if
9 // possible so the DeepEqual performed will not fail if one parameter is a
10 // pointer and the other is not.
12 // DeepEqual will not perform indirection of nested values of the input parameters.
13 func DeepEqual(a, b interface{}) bool {
14 ra := reflect.Indirect(reflect.ValueOf(a))
15 rb := reflect.Indirect(reflect.ValueOf(b))
17 if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid {
18 // If the elements are both nil, and of the same type they are equal
19 // If they are of different types they are not equal
20 return reflect.TypeOf(a) == reflect.TypeOf(b)
21 } else if raValid != rbValid {
22 // Both values must be valid to be equal
26 return reflect.DeepEqual(ra.Interface(), rb.Interface())