O'Reilly logo

Learning Go Programming by Vladimir Vivien

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Boolean type

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required