Skip to content

Commit

Permalink
feat: add simple access control golang
Browse files Browse the repository at this point in the history
  • Loading branch information
trmaphi committed Mar 10, 2021
1 parent 0777152 commit cd82b8f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions simple-accesscontrol-go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"fmt"
)

const (
isAdmin = 1 << iota
isHeadquarters
canSeeFinancials

canSeeAfrica
canSeeAsia
)

func main() {
var roles byte = isAdmin | canSeeAfrica | canSeeAsia;
fmt.Printf("%b\n", roles);
fmt.Printf("Is admin? %v\n", isAdmin & roles == isAdmin);
fmt.Printf("Is HQ? %v\n", isHeadquarters & roles == isHeadquarters);
}

0 comments on commit cd82b8f

Please sign in to comment.