@@ -4,12 +4,12 @@ import (
44 "fmt"
55 "github.com/mohae/utilitybelt/deepcopy"
66 //"golang.org/x/tools/go/types"
7+ "errors"
78 "go/token"
89 "go/types"
910 "reflect"
1011 "strconv"
1112 "strings"
12- "errors"
1313)
1414
1515var ErrGetFromNullObj = errors .New ("get attribute from null object" )
@@ -417,9 +417,12 @@ func parse_filter(filter string) (lp string, op string, rp string, err error) {
417417 str_embrace = true
418418 } else {
419419 switch stage {
420- case 0 : lp = tmp
421- case 1 : op = tmp
422- case 2 : rp = tmp
420+ case 0 :
421+ lp = tmp
422+ case 1 :
423+ op = tmp
424+ case 2 :
425+ rp = tmp
423426 }
424427 tmp = ""
425428 }
@@ -429,15 +432,18 @@ func parse_filter(filter string) (lp string, op string, rp string, err error) {
429432 continue
430433 }
431434 switch stage {
432- case 0 : lp = tmp
433- case 1 : op = tmp
434- case 2 : rp = tmp
435+ case 0 :
436+ lp = tmp
437+ case 1 :
438+ op = tmp
439+ case 2 :
440+ rp = tmp
435441 }
436442 tmp = ""
437443
438444 stage += 1
439445 if stage > 2 {
440- return "" , "" , "" , errors .New (fmt .Sprintf ("invalid char at %d: `%s `" , idx , c ))
446+ return "" , "" , "" , errors .New (fmt .Sprintf ("invalid char at %d: `%c `" , idx , c ))
441447 }
442448 default :
443449 tmp += string (c )
@@ -448,8 +454,10 @@ func parse_filter(filter string) (lp string, op string, rp string, err error) {
448454 case 0 :
449455 lp = tmp
450456 op = "exists"
451- case 1 : op = tmp
452- case 2 : rp = tmp
457+ case 1 :
458+ op = tmp
459+ case 2 :
460+ rp = tmp
453461 }
454462 tmp = ""
455463 }
@@ -528,11 +536,11 @@ func eval_filter(obj, root interface{}, lp, op, rp string) (res bool, err error)
528536
529537func isNumber (o interface {}) bool {
530538 switch v := o .(type ) {
531- case int ,int8 ,int16 ,int32 ,int64 :
539+ case int , int8 , int16 , int32 , int64 :
532540 return true
533- case uint ,uint8 ,uint16 ,uint32 ,uint64 :
541+ case uint , uint8 , uint16 , uint32 , uint64 :
534542 return true
535- case float32 ,float64 :
543+ case float32 , float64 :
536544 return true
537545 case string :
538546 _ , err := strconv .ParseFloat (v , 64 )
0 commit comments