From 558d6ae7d015d17d1702751789c7d06c6e37c5e2 Mon Sep 17 00:00:00 2001 From: ston1th Date: Sun, 9 Jul 2017 20:34:58 +0200 Subject: [PATCH] fixed typo and cleaner helper --- filter.go | 2 +- helper.go | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/filter.go b/filter.go index 983334f..e39b552 100644 --- a/filter.go +++ b/filter.go @@ -180,7 +180,7 @@ func (q *Query) GenericFilter(i interface{}) interface{} { } // Filter takes a pointer to the Filter interface as an argument. -// The original slice is modified is the filtering process. +// The original slice is modified in the filtering process. func (q Query) Filter(f Filter) { count := 0 i := 0 diff --git a/helper.go b/helper.go index bf8753b..7acdcf3 100644 --- a/helper.go +++ b/helper.go @@ -59,28 +59,34 @@ func matchFunc(v string) func(string) bool { return false } } -func boolFunc(v string) func(bool) bool { - f := func(b bool) bool { - return false + +func ft(b bool) bool { + if b { + return true } + return false +} + +func ff(b bool) bool { + if !b { + return true + } + return false +} + +func f(b bool) bool { + return false +} + +func boolFunc(v string) func(bool) bool { if len(v) == 0 { return f } if v[0] == 't' { - return func(b bool) bool { - if b { - return true - } - return false - } + return ft } if v[0] == 'f' { - return func(b bool) bool { - if !b { - return true - } - return false - } + return ff } return f }