35 lines
741 B
Go
35 lines
741 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"sort"
|
||
|
|
||
|
"github.com/pyke369/golang-support/uconfig"
|
||
|
)
|
||
|
|
||
|
// check if there is a member of "search" in "list". sort list to be more
|
||
|
// efficiant. adapt with sorting "search" too
|
||
|
func inArray(search, list []string) bool {
|
||
|
sort.Strings(list)
|
||
|
for _, g := range search {
|
||
|
i := sort.Search(len(list), func(i int) bool { return list[i] >= g })
|
||
|
if i < len(list) && list[i] == g {
|
||
|
return true
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
// parse a uconf array
|
||
|
func parseConfigArray(config *uconfig.UConfig, configpath string) []string {
|
||
|
result := []string{}
|
||
|
for _, i := range config.GetPaths(configpath) {
|
||
|
if s := config.GetString(i, ""); s == "" {
|
||
|
continue
|
||
|
} else {
|
||
|
result = append(result, s)
|
||
|
}
|
||
|
}
|
||
|
return result
|
||
|
}
|