October 2016
Beginner
348 pages
6h 31m
English
In Go, Boolean binary values are stored using the bool type. Although a variable of type bool is stored as a 1-byte value, it is not, however, an alias for a numeric value. Go provides two pre-declared literals, true and false, to represent Boolean values as shown in the following example:
package main
import "fmt"
func main() {
var readyToGo bool = false
if !readyToGo {
fmt.Println("Come on")
} else {
fmt.Println("Let's go!")
}
}
golang.fyi/ch04/bool.go
Read now
Unlock full access