diff --git a/utils/utils.go b/utils/utils.go index 64e0101f8227a5bd8f8d285f350997127a0109e8..1252424f69a2f7f7a628b34566e4759ca0452ff4 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -1,12 +1,14 @@ package utils import ( + "bytes" "github.com/mohae/deepcopy" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/errors" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/string_utils" "net/mail" "net/url" "os" + "reflect" "regexp" "strings" ) @@ -145,3 +147,26 @@ func EscapeOpenSearchSearchString(str string) string { } return searchString } + +// IsEqual returns if the two objects are equal +func IsEqual(expected interface{}, actual interface{}) bool { + if expected == nil || actual == nil { + return expected == actual + } + + if exp, ok := expected.([]byte); ok { + act, ok := actual.([]byte) + if !ok { + return false + } + + if exp == nil || act == nil { + return true + } + + return bytes.Equal(exp, act) + } + + return reflect.DeepEqual(expected, actual) + +}