
The Go Workshop
By :

True and false logic is represented using the Boolean type, bool
. Use this type when you need an on/off switch in your code. The value of a bool
can only ever be true
or false
. The zero value of a bool
is false
.
When using a comparison operator such as ==
or >
, the result of that comparison is a bool
value.
In this code example, we use comparison operators on two numbers. You'll see that the result is a bool
:
package main import "fmt" func main() { fmt.Println(10 > 5) fmt.Println(10 == 5) }
Running the preceding code shows the following output:
true false
An online portal creates user accounts for its users and accepts passwords that are only 8-15 characters long. In this exercise, we write a program for the portal to display whether the password entered meets the character requirements. The character requirements are as follows: