How to represent the Boolean "true" and "false" in Go

1 Answer

0 votes
// In Go (Golang), Boolean values are represented using the built‑in literals:
// true
// false

// The Boolean type is: bool

package main

import (
    "fmt"
)

func main() {
    isActive := true    
    isFinished := false  

    fmt.Println("isActive =", isActive)
    fmt.Println("isFinished =", isFinished)

    // Boolean expression example
    result := (10 > 3)
    fmt.Println("10 > 3 evaluates to:", result)
}


/*
run:

isActive = true
isFinished = false
10 > 3 evaluates to: true

*/

 



answered Apr 15 by avibootz
edited Apr 15 by avibootz
...