...

Source file src/github.com/aws/aws-sdk-go-v2/internal/awsutil/equal.go

Documentation: github.com/aws/aws-sdk-go-v2/internal/awsutil

     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 the 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  	// Special casing for strings as typed enumerations are string aliases
    27  	// but are not deep equal.
    28  	if ra.Kind() == reflect.String && rb.Kind() == reflect.String {
    29  		return ra.String() == rb.String()
    30  	}
    31  
    32  	return reflect.DeepEqual(ra.Interface(), rb.Interface())
    33  }
    34  

View as plain text