fixed typo and cleaner helper

This commit is contained in:
ston1th 2017-07-09 20:34:58 +02:00
commit 558d6ae7d0
2 changed files with 22 additions and 16 deletions

View file

@ -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

View file

@ -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
}