×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

What is the default value of a bool variable in Go language?

In this tutorial, we are going to learn about the bool variable and the default value of a bool variable in Go language.
Submitted by IncludeHelp, on October 02, 2021

The bool is a built-in data type in Go language, it can store either "true" or "false". The default value of a bool variable is "false".

Example:

// Golang program to demonstrate the
// default value of bool variable

package main

import (
	"fmt"
)

func main() {
	var x bool
	fmt.Println("Default value of bool is", x)
}

Output:

Default value of bool is false

Golang FAQ »



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.