In order to control the flow of an application, Go offers different tools – some statements like if/else, switch, and for are used in sequential scenarios, whereas others like go and select are used in concurrent ones.
Understanding flow control
Condition
The if statement verifies a binary condition and executes the code inside the if block when the condition is true. When an else block is present, it's executed when the condition is false. This statement also allows a short declaration before the condition, separated by a ;. This condition can be chained with an else if statement, as shown in the following code:
if r := a%10; r != 0 { // if with short declaration
if r > 5 { /...