mirror of
https://github.com/1f349/lavender.git
synced 2024-11-09 22:32:48 +00:00
26 lines
420 B
Go
26 lines
420 B
Go
package server
|
|
|
|
import (
|
|
"bufio"
|
|
"strings"
|
|
)
|
|
|
|
func HasRole(roles, test string) bool {
|
|
sc := bufio.NewScanner(strings.NewReader(roles))
|
|
sc.Split(bufio.ScanWords)
|
|
for sc.Scan() {
|
|
if sc.Text() == test {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func ForEachRole(roles string, next func(role string)) {
|
|
sc := bufio.NewScanner(strings.NewReader(roles))
|
|
sc.Split(bufio.ScanWords)
|
|
for sc.Scan() {
|
|
next(sc.Text())
|
|
}
|
|
}
|