Essential Go Basic types  Edit on GitHub      File Issue


Value of type bool can be true or false.

var b bool = true
fmt.Printf("b is: '%v'\n", b)
b = false
fmt.Printf("b is: '%v'\n", b)
b is: 'true'
b is: 'false'

Size of bool variable (e.g. when part of a struct) is 1 byte.

b := true
fmt.Printf("size of bool is: %d\n", unsafe.Sizeof(b))
size of bool is: 1

Zero value of bool is false.

  ↑ ↓ to navigate     ↵ to select     Esc to close