Go language conditional statement
A conditional statement requires the developer to decide whether to execute the specified statement by specifying one or more conditions and by testing whether the condition is true, and executing another statement if the condition is false.
The following figure shows the structure of a conditional statement in a programming language:
|Sr.No||Statement & Description|
An if statement consists of a Boolean expression followed by one or more statements.
An optional else statement can be used after the if statement, and the expression in the else statement is executed when the Boolean expression is false.
nested if statements
You can embed one or more if or else if statements in an if or else if statement.
The switch statement is used to perform different actions based on different conditions.
A select statement is similar to a switch statement, but select randomly executes a runnable case. If there is no case to run, it will block until there is a case to run.