So I just started learning GoLang. I'm trying to perform a bitwise operation XOR between two byte (uint8) numbers. Every time I run the command "go vet" I get the following error:
undefined: xˆy
My code:
package main
import (
"fmt"
"math"
)
func main() {
var x byte = 1
var y byte = 2
fmt.Println("XOR x and y =", xˆy)
}
You are using the wrong character.
Don't use ˆ
. Use ^
.
package main
import (
"fmt"
)
func main() {
var x byte = 1
var y byte = 2
fmt.Println("XOR x and y =", x^y)
}
Output:
XOR x and y = 3