To print a boolean value in Go, you can “use the fmt.Println() or fmt.Printf() functions. In Go, the fmt package provides various functions for formatted I/O operations. Among these, fmt.Println() and fmt.Printf() is commonly used for printing.
Method 1: Using the fmt.Println() function
The fmt.Println() function prints the arguments it receives and appends a newline character at the end. It can be used to print a boolean value directly:
package main
import (
"fmt"
)
func main() {
isTrue := true
fmt.Println("The boolean value is:", isTrue)
}
Output
The boolean value is: true
Method 2: Using the fmt.Printf() function
You can also use the fmt.Printf() function with the %t verb, specifically used to format boolean values.
package main
import (
"fmt"
)
func main() {
isTrue := true
fmt.Printf("The boolean value is: %t\n", isTrue)
}
Output
The boolean value is: true
Remember to use %t as the format specifier for boolean values when using fmt.Printf() function.
That’s it.
Related posts
Print the Values of Slices of Go

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.