github.com/aavshr/aws-sdk-go@v1.41.3/aws/awsutil/equal.go (about) 1 package awsutil 2 3 import ( 4 "reflect" 5 ) 6 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. 11 // 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)) 16 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 23 return false 24 } 25 26 return reflect.DeepEqual(ra.Interface(), rb.Interface()) 27 }