From 5db7e2f01bfb0d6cc43ec98baaa32fe797df4c0e Mon Sep 17 00:00:00 2001 From: boyska Date: Wed, 26 Dec 2018 01:54:30 +0100 Subject: [PATCH] filtering code cleanup --- filtering/filter.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/filtering/filter.go b/filtering/filter.go index 0deebed..bc3f825 100644 --- a/filtering/filter.go +++ b/filtering/filter.go @@ -48,12 +48,9 @@ func (e *ExprValue) Validate(line map[string]interface{}) bool { if !ok || val == nil { // errors when evaluating return false } - if val.Type() != value.BoolType { - fmt.Fprintln(os.Stderr, "WARNING: The 'where' expression doesn't return a boolean") - return false + if bv, isBool := val.(value.BoolValue); isBool { + return bv.Val() } - if val.Value().(bool) != true { - return false - } - return true + fmt.Fprintln(os.Stderr, "WARNING: The 'where' expression doesn't return a boolean") + return false }