13. Boolean

Boolean(bool) Type

Boolean has only two possible values, true and false

Conditions and comparison operators needs value to be bool Type.

main.go
package main
import "fmt"
func main() {
var shouldGo bool = true
if shouldGo {
fmt.Println("I should Go!")
}
}

Declaring Boolean

Boolean are declared using one of the following ways:

main.go
var shouldBe bool = true
var shouldBe = true
shouldBe :=true

Zero value for bool is false