The While Loop
Go does not have a while keyword. Instead, a while loop is represented as a for loop that only includes a CONDITION.
Syntax
for CONDITION {
// do something while CONDITION is true
}
Example
count := 1
for count < 5 {
fmt.Println(count)
count++
}
Logic Review
Since loops often rely on conditions, remember the standard logical operators:
- AND:
&& - OR:
|| - NOT:
! - Modulo:
%(Useful for every Nth iteration)