From 48a1615fdb114f0e345f019be0c28615a456e04d Mon Sep 17 00:00:00 2001 From: Florian Obernbrger <99478384+florian-obernberger@users.noreply.github.com> Date: Fri, 3 Jun 2022 09:29:38 +0200 Subject: [PATCH] Fixed eq, in and holds --- query.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/query.go b/query.go index 1035bfc..6a43877 100644 --- a/query.go +++ b/query.go @@ -44,9 +44,13 @@ type QueryFunc func(x, y interface{}) (bool, error) // eq checks whether x, y are deeply eq func eq(x, y interface{}) (bool, error) { // if the y value is numeric (int/int8-int64/float32/float64) then convert to float64 - if fv, ok := toFloat64(y); ok { - y = fv - } + // if fv, ok := toFloat64(y); ok { + // y = fv + // } + // commenting this out since it returns false for: + // + // var a int, var b int = 3, 3 + // fmt.Println(eq(a, b)) // → false return reflect.DeepEqual(x, y), nil } @@ -166,8 +170,6 @@ func strEndsWith(x, y interface{}) (bool, error) { func in(x, y interface{}) (bool, error) { if yv, ok := y.([]string); ok { for _, v := range yv { - fmt.Printf("vy: %s\n", v) - fmt.Printf("x: %s\n", x) if ok, _ := eq(x, v); ok { return true, nil } @@ -199,9 +201,6 @@ func notIn(x, y interface{}) (bool, error) { // holds checks if x contains y e.g: holds("[1,2,3]", 1) func holds(x, y interface{}) (bool, error) { b, err := in(y, x) - fmt.Printf("x: %s\n\ttype: %t\n", x, x) - fmt.Printf("y: %s\n\ttype: %t\n", y, y) - fmt.Printf("y holds y: %t", b) return b, err }