Go provides if/else and switch conditional statements for code execution based on certain conditions. To execute some code over and over again, we have the for loop.

The if/else conditional statement

Go provides if, if-else, if-else if-else variants of if/else statement we are familiar with. It is used to check a condition, and execute some code when the condition is true or false.

The if condition

Simple use of if condition is demonstrated below. Unlike most of the programming languages, Go does not allow to wrap the condition inside parenthesis ().

#golang #programming #golang-tutorial #go-tutorial #go

Anatomy of Conditional Statements and Loops in Go
2.35 GEEK