]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / aws / awsutil / equal.go
CommitLineData
bae9f6d2
JC
1package awsutil
2
3import (
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.
13func 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 {
107c1cdb 18 // If the elements are both nil, and of the same type they are equal
bae9f6d2
JC
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}