Description
Operators that work on bits. `&` (AND), `|` (OR), `^` (XOR), `<<` (Left Shift), `>>` (Right Shift), `&^` (Bit Clear).
Pros & Cons
✅ Pros
- Low-level manipulation.
- Performance optimizations.
❌ Cons
- Complexity: Harder to read.
When to Use
Cryptography, flags, and hardware protocols.
Example
Bit manipulation.
var x uint8 = 0b00001100 // 12
var y uint8 = 0b00001010 // 10
fmt.Printf("%08b\n", x & y) // AND
fmt.Printf("%08b\n", x | y) // OR
fmt.Printf("%08b\n", x ^ y) // XOR
Best Practices
Go has a special `&^` AND NOT operator useful for clearing bits.
