Go Decision Making

In this tutorial you will learn about the Go Decision Making and its application with practical example.

Go Decision Making Statements

There are case where we want a a block of code to be executed when some condition is satisfied. In Go, we have Decision Making Statement that enable computer to decide which block of code to be execute based on some conditional choices. Decision making statement statements is also referred to as selection statements.

Table Of Contents

Decision making statement evaluates single or multiple test expressions which results is “TRUE” or “FALSE”. The outcome of the test expression/condition helps to determine which block of statement(s) to executed if the condition is “TRUE” or “FALSE” otherwise.

In Go, we have following types of decision making statements –

Go Decision Making Statements
Statement Description
if Statements Block of statement executed only when specified test expression is true.
if else Statements When we want to execute some block of code if a condition is true and another block of code if a condition is false, In such a case we use if….else statement.
Nested If Statements When there is an if statement inside another if statement then it is known as nested if else.
Switch Statement A switch statement evaluates an expression against multiple cases in order to identify the block of code to be executed.
Select Statement It allows to chooses among possible send or receive operations. It looks similar to “switch” statement but is used for communication operations.

In this tutorial we have learn about the Go Decision Making and its application with practical example. I hope you will like this tutorial.