gitlab.com/evatix-go/core@v1.3.55/internal/reflectinternal/IsConclusive.go (about)

     1  package reflectinternal
     2  
     3  import "reflect"
     4  
     5  func IsConclusive(left, right interface{}) (isEqual, isConclusive bool) {
     6  	if left == right {
     7  		return true, true
     8  	}
     9  
    10  	if left == nil && right == nil {
    11  		return true, true
    12  	}
    13  
    14  	if left == nil || right == nil {
    15  		return false, true
    16  	}
    17  
    18  	leftRv := reflect.ValueOf(left)
    19  	rightRv := reflect.ValueOf(right)
    20  	isLeftNull := IsNullUsingReflectValue(leftRv)
    21  	isRightNull := IsNullUsingReflectValue(rightRv)
    22  	isBothEqual := isLeftNull == isRightNull
    23  
    24  	if isLeftNull && isBothEqual {
    25  		// both null
    26  		return true, true
    27  	} else if !isBothEqual && isLeftNull || isRightNull {
    28  		// any null but the other is not
    29  		return false, true
    30  	}
    31  
    32  	if leftRv.Type() != rightRv.Type() {
    33  		return false, true
    34  	}
    35  
    36  	return false, false
    37  }