MCPcopy
hub / github.com/duke-git/lancet / compareValue

Function compareValue

compare/compare_internal.go:13–38  ·  view source on GitHub ↗
(operator string, left, right any)

Source from the content-addressed store, hash-verified

11)
12
13func compareValue(operator string, left, right any) bool {
14 leftType, rightType := reflect.TypeOf(left), reflect.TypeOf(right)
15
16 if leftType.Kind() != rightType.Kind() {
17 return false
18 }
19
20 switch leftType.Kind() {
21 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
22 reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
23 reflect.Float32, reflect.Float64, reflect.Bool, reflect.String:
24 return compareBasicValue(operator, left, right)
25
26 case reflect.Struct, reflect.Slice, reflect.Map:
27 return compareRefValue(operator, left, right, leftType.Kind())
28
29 case reflect.Ptr:
30 if leftVal, ok := left.(*big.Int); ok {
31 if rightVal, ok := right.(*big.Int); ok {
32 return compareBigInt(operator, leftVal, rightVal)
33 }
34 }
35 }
36
37 return false
38}
39
40func compareRefValue(operator string, leftObj, rightObj any, kind reflect.Kind) bool {
41 leftVal, rightVal := reflect.ValueOf(leftObj), reflect.ValueOf(rightObj)

Callers 5

EqualFunction · 0.85
LessThanFunction · 0.85
GreaterThanFunction · 0.85
LessOrEqualFunction · 0.85
GreaterOrEqualFunction · 0.85

Calls 4

compareBasicValueFunction · 0.85
compareRefValueFunction · 0.85
compareBigIntFunction · 0.85
KindMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…