
Introduction
Conditional statements are part of every programming language. With conditional statements, we can have code that sometimes runs and at other times does not run, depending on the conditions of the program at that time.
When we fully execute each statement of a program, we are not asking the program to evaluate specific conditions. By using conditional statements, programs can determine whether certain conditions are being met and then be told what to do next.
Let’s look at some examples where we would use conditional statements:
If the student receives over 65% on her test, report that her grade passes; if not, report that her grade fails.
If he has money in his account, calculate interest; if he doesn’t, charge a penalty fee.
If they buy 10 oranges or more, calculate a discount of 5%; if they buy fewer, then don’t.
Through evaluating conditions and assigning code to run based on whether or not those conditions are met, we are writing conditional code.
This tutorial will take you through writing conditional statements in the Go programming language.
Read more here