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
.
if/else
conditional statementGo 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
.
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