Skip to content

Commit a3e2184

Browse files
authored
export IsNil and IsNotNil (#19)
Need to use in custom compare or setting defaults ### Testing Locally in sagemaker code, will have a PR out soon
1 parent 362aca3 commit a3e2184

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/compare/nil.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ import (
2020
// HasNilDifference returns true if the supplied subjects' nilness is
2121
// different
2222
func HasNilDifference(a, b interface{}) bool {
23-
if isNil(a) || isNil(b) {
24-
if (isNil(a) && isNotNil(b)) || (isNil(b) && isNotNil(a)) {
23+
if IsNil(a) || IsNil(b) {
24+
if (IsNil(a) && IsNotNil(b)) || (IsNil(b) && IsNotNil(a)) {
2525
return true
2626
}
2727
}
2828
return false
2929
}
3030

31-
// isNil checks the passed interface argument for Nil value.
31+
// IsNil checks the passed interface argument for Nil value.
3232
// For interfaces, only 'i==nil' check is not sufficient.
3333
// https://tour.golang.org/methods/12
3434
// More details: https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1
35-
func isNil(i interface{}) bool {
35+
func IsNil(i interface{}) bool {
3636
if i == nil {
3737
return true
3838
}
@@ -44,6 +44,6 @@ func isNil(i interface{}) bool {
4444
return false
4545
}
4646

47-
func isNotNil(i interface{}) bool {
48-
return !isNil(i)
47+
func IsNotNil(i interface{}) bool {
48+
return !IsNil(i)
4949
}

0 commit comments

Comments
 (0)