non-bool value in if condition in Go

Viewed 7751

I have an if statement in Go which looks like this:

if level & 1 {
    // do something
} else {
    // do something else
}

The level variable in my cause is of type uint. But when I do bitwise AND with 1, the result is not a boolean. This is a valid syntax for C, but apparently it doesn't work in Go. Any idea how to work around this?

1 Answers
Related