gitlab.com/evatix-go/core@v1.3.55/isany/Conclusive.go (about)

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