×

Go Tutorial

Go Basics

Go Variables

Go Literals

Go Type Handling

Go Operators

Go Decision Making

Go Loops

Go Functions

Go String

Go Arrays

Go Slices

Go Maps

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang true and false Constants with Examples

Golang | true and false Constants: Here, we are going to learn about the true and false constants with examples.
Submitted by IncludeHelp, on October 12, 2021 [Last updated : March 15, 2023]

true and false Constants

In the Go programming language, true and false are the two untyped boolean values, these are boolean constants.

Syntax

true
false

Parameter(s)

  • None

Return Value

None

Example 1

// Golang program to demonstrate the
// example of true and false constants

package main

import (
	"fmt"
)

func main() {
	// Printing the values and types
	// of true and false
	fmt.Printf("%T, %v\n", true, true)
	fmt.Printf("%T, %v\n", false, false)
}

Output

bool, true
bool, false

Example 2

// Golang program to demonstrate the
// example of true and false constants

package main

import (
	"fmt"
)

func main() {
	age := 21
	// Comparison of the expression
	if age >= 18 == true {
		fmt.Println("Eligible for voting")
	} else {
		fmt.Println("Not eligible for voting")
	}
}

Output

Eligible for voting

Golang builtin Package »



Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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