paint-brush
Using Bitwise Operators To Handle Permissions in GOby@d8me
1,611 reads
1,611 reads

Using Bitwise Operators To Handle Permissions in GO

by Akshit2mMay 8th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Using Bitwise Operators To Handle Permissions in GO, I stumbled across a very interesting approach to give permissions (or roles) to users in the system. The idea is to have each bit in a binary sequence denote a permission, similar to how chmod number permission works. In this way we can store multiple permissions in a single byte. To verify the permissions, we can just do an AND operation and check the value with the permission. The output of the snippet above is: IsDevOps? true IsDev Ops? True IsDevops: true IsAdmin? True isDevOps.

Coin Mentioned

Mention Thumbnail
featured image - Using Bitwise Operators To Handle Permissions in GO
Akshit HackerNoon profile picture
Akshit

Akshit

@d8me

L O A D I N G
. . . comments & more!

About Author

Akshit HackerNoon profile picture
Akshit@d8me

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite