mirror of
https://github.com/onyx-and-iris/gogn.git
synced 2026-04-16 14:23:35 +00:00
initial commit
This commit is contained in:
19
filter.go
Normal file
19
filter.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// filterFunc returns a function that filters templates based on the specified filter type.
|
||||
func filterFunc(templates []string, filterType string) func(input string, index int) bool {
|
||||
switch filterType {
|
||||
case "contains":
|
||||
return func(input string, index int) bool {
|
||||
return strings.Contains(strings.ToLower(templates[index]), strings.ToLower(input))
|
||||
}
|
||||
default:
|
||||
return func(input string, index int) bool {
|
||||
return strings.HasPrefix(strings.ToLower(templates[index]), strings.ToLower(input))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user