// remove Alpha
flags ^= Alpha
This is a bitwise XOR operation and will basically flip Alpha. If it is set it becomes unset and vice versa. When you repeat the instruction:
// remove Alpha
flags ^= Alpha
if flags&Alpha == 0 {
fmt.Println("Alpha is not set")
}
// remove Alpha
flags ^= Alpha
if flags&Alpha == 0 {
fmt.Println("Alpha is not set")
}
it will output "Alpha is not set" only once, because the second time, Alpha is set again.
To truly remove Alpha use
// remove Alpha
flags &^= Alpha
this is the AND NOT operator and will clear the Alpha flag from flags whether it is set or unset.
Go Happy!
Wilbert