What is type bool in Golang?

Variables contain data, and data can be of different data types, or types for short. Golang is a statically typed language; this means the compiler must know the types of all the variables, either because they were explicitly indicated or because the compiler can infer the type from the code context. A type defines the set of values and the set of operations that can take place on those values.

Type bool in Golang is the set of Boolean values, True or False. Below is how you declare a variable of type bool:

var var_name bool

Example

package main
import "fmt"
func main() {
var var1 bool = true
fmt.Printf("Type of var1: %T", var1)
}

Explanation

The above code declares the variable var1 with type bool, and displays its type using the Printf method from the fmt package.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved