Skip to content

Instantly share code, notes, and snippets.

@bbengfort
Created Jul 26, 2019
Embed
What would you like to do?
type Bitmask uint8
const (
F0 bitmask = 1 << iota
F1
F2
)
func Set(b, flag Bitmask) Bitmask { return b | flag }
func Clear(b, flag Bitmask) Bitmask { return b &^ flag }
func Toggle(b, flag Bitmask) Bitmask { return b ^ flag }
func Has(b, flag Bitmask) bool { return b&flag != 0 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment