Go Tutorial #5: Control Flow — if, switch, for
In the previous tutorial, you learned about functions and error handling. Now it is time to learn how to control the flow of your program with if, switch, and for. Go keeps control flow simple. There is only one loop keyword: for. No while, no do-while. Just for. The switch statement is also simpler and more powerful than in most languages. if / else The basic if statement works like most languages. But Go does not need parentheses around the condition: ...