mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-19 07:01:02 +01:00
5b7e8d1309
* lib/backup/s3remote: update AWS SDK to v2 * Update lib/backup/s3remote/s3.go Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com> * lib/backup/s3remote: refactor error handling Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package awsutil
|
|
|
|
import (
|
|
"reflect"
|
|
)
|
|
|
|
// DeepEqual returns if the two values are deeply equal like reflect.DeepEqual.
|
|
// In addition to this, this method will also dereference the input values if
|
|
// possible so the DeepEqual performed will not fail if one parameter is a
|
|
// pointer and the other is not.
|
|
//
|
|
// DeepEqual will not perform indirection of nested values of the input parameters.
|
|
func DeepEqual(a, b interface{}) bool {
|
|
ra := reflect.Indirect(reflect.ValueOf(a))
|
|
rb := reflect.Indirect(reflect.ValueOf(b))
|
|
|
|
if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid {
|
|
// If the elements are both nil, and of the same type the are equal
|
|
// If they are of different types they are not equal
|
|
return reflect.TypeOf(a) == reflect.TypeOf(b)
|
|
} else if raValid != rbValid {
|
|
// Both values must be valid to be equal
|
|
return false
|
|
}
|
|
|
|
// Special casing for strings as typed enumerations are string aliases
|
|
// but are not deep equal.
|
|
if ra.Kind() == reflect.String && rb.Kind() == reflect.String {
|
|
return ra.String() == rb.String()
|
|
}
|
|
|
|
return reflect.DeepEqual(ra.Interface(), rb.Interface())
|
|
}
|