Add HasPerms helper func (#56)

master
HimbeerserverDE 2021-09-09 16:19:21 +02:00
parent 2e3d72cccc
commit ee65321a24
No known key found for this signature in database
GPG Key ID: 1A651504791E6A8B
1 changed files with 15 additions and 0 deletions

View File

@ -18,3 +18,18 @@ func (cc *ClientConn) Perms() []string {
return []string{}
}
func (cc *ClientConn) HasPerms(want ...string) bool {
has := make(map[string]struct{})
for _, perm := range cc.Perms() {
has[perm] = struct{}{}
}
for _, perm := range want {
if _, ok := has[perm]; !ok {
return false
}
}
return true
}