How to print bool in golang?

Hi 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;

when we run the above code, we get false in the console. check the following image.

print, boolean, golang

Try it yourself

All the best 👍

Follow me on Twitter