mirror of
https://github.com/coaidev/coai.git
synced 2025-05-20 21:40:15 +09:00
25 lines
456 B
Go
25 lines
456 B
Go
package api
|
|
|
|
import "strings"
|
|
|
|
func FilterKeys(keys string) string {
|
|
stack := make(chan string, len(strings.Split(keys, "|")))
|
|
for _, key := range strings.Split(keys, "|") {
|
|
go func(key string) {
|
|
if TestKey(key) {
|
|
stack <- key
|
|
} else {
|
|
stack <- ""
|
|
}
|
|
}(key)
|
|
}
|
|
|
|
var result string
|
|
for i := 0; i < len(strings.Split(keys, "|")); i++ {
|
|
if res := <-stack; res != "" {
|
|
result += res + "|"
|
|
}
|
|
}
|
|
return strings.Trim(result, "|")
|
|
}
|