How to print bool in golang?
April 11, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
Today, I’m going to show you how to print the boolean variable value in golang, for print anything we have the fmt.Printf()
method and in this tutorial, we will use it.
So, when we want to print any bool value, we must pass %t
in the fmt.Printf()
method.
let’s start writing code.
package main
import "fmt"
func main() {
b := false;
fmt.Printf("%t",b)
}
when we run the above code, we get false in the console. check the following image.
All the best 👍