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;
  fmt.Printf("%t",b)
}

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 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts