Welcome To Golang By Example

Format specifier for boolean or print boolean in Go (Golang)

Different format specifiers can be used to print a boolean in either bool or string.

Code:

package main

import "fmt"

func main() {
	t := true
	f := false

	fmt.Printf("%t %t\n", t, f)
	fmt.Printf("%v %v\n", t, f)
}

Output

true false
true false