位操作运算符&^用于按位置零(AND NOT)(按y置零x):

表达式z = x &^ y结果z

如果对应y中bit位为1的话,z的bit位为0,否则对应的bit位等于x相应的bit位的值。

var x uint8 = 1<<1 | 1<<5
var y uint8 = 1<<1 | 1<<2
fmt.Printf("%08b\n", x) // "00100010", the set {1, 5}
fmt.Printf("%08b\n", y) // "00000110", the set {1, 2}
fmt.Printf("%08b\n", x&^y) // "00100000", the difference {5}