EasyEnv
Engineering/Courses/Catalog/Go/Control Flow: if and for
Go
BeginnerLesson 3 of 2030 min · hands-on

Control Flow: if and for

Part of the Go course

So far every program you have written runs top to bottom, one line after another, with no choices along the way. Real programs need to react: charge a different shipping rate for a big order, print a different message for an adult than for a minor, keep asking a server for a response until one arrives.

Think of if the way you would think of a fork in a hallway with a sign on it: if a condition is true, go one way, otherwise go the other. Here is the smallest version ...

Want to learn Go Control Flow: if and for in a real environment?

Click below, get a fresh Linux box with Go ready to go, and work through Control Flow: if and for hands-on with an AI tutor that knows your code.

Start this lessonControl Flow: if and for

What you'll learn

  • If
  • Else if
  • Else
  • For loop
  • For as while
  • Infinite for
  • Break
  • Continue

Read this lesson in your language

All lessons in this course

20 lessons
  1. 1Hello, Go25 min
  2. 2Variables and Types25 min
  3. 3Control Flow: if and for30 min
  4. 4Functions30 min
  5. 5Slices and Maps35 min
  6. 6Structs and Pointers35 min
  7. 7Methods and Interfaces35 min
  8. 8Error Handling35 min
  9. 9Modules and Project Structure35 min
  10. 10Tiny CLI Capstone40 min
  11. 11A Tour of the Standard Library40 min
  12. 12Testing and Benchmarks40 min
  13. 13Goroutines and Channels40 min
  14. 14Concurrency Patterns45 min
  15. 15Generics35 min
  16. 16HTTP Servers45 min
  17. 17Databases with database/sql45 min
  18. 18Performance and Profiling40 min
  19. 19Design Patterns in Go40 min
  20. 20Deployment and Production45 min

Explore other courses

Control Flow: if and for - Go (English) | Engineering Courses