fixed typo and cleaner helper
This commit is contained in:
parent
6d41615250
commit
558d6ae7d0
2 changed files with 22 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
36
helper.go
36
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue