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 forWhat 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- 1Hello, Go25 min
- 2Variables and Types25 min
- 3Control Flow: if and for30 min
- 4Functions30 min
- 5Slices and Maps35 min
- 6Structs and Pointers35 min
- 7Methods and Interfaces35 min
- 8Error Handling35 min
- 9Modules and Project Structure35 min
- 10Tiny CLI Capstone40 min
- 11A Tour of the Standard Library40 min
- 12Testing and Benchmarks40 min
- 13Goroutines and Channels40 min
- 14Concurrency Patterns45 min
- 15Generics35 min
- 16HTTP Servers45 min
- 17Databases with database/sql45 min
- 18Performance and Profiling40 min
- 19Design Patterns in Go40 min
- 20Deployment and Production45 min
Explore other courses
Python
19 lessons 路 9.3h
React
17 lessons 路 10.2h
Linux
17 lessons 路 8.5h
Docker
13 lessons 路 6.6h
Git
13 lessons 路 5.9h
Kubernetes
14 lessons 路 8h
Ansible
12 lessons 路 6.1h
Bash
12 lessons 路 5.7h
Helm
10 lessons 路 5.4h
GitLab CI
11 lessons 路 5.8h
Jenkins
11 lessons 路 5.3h
PostgreSQL
14 lessons 路 7.6h
MySQL
13 lessons 路 6.8h
Web
14 lessons 路 5.9h
TypeScript
18 lessons 路 7.7h
Vibe Coding
12 lessons 路 5.8h
Prompt Engineering
11 lessons 路 6.2h
Vibe Coding: Fundamentals
12 lessons 路 4.5h
Vibe Coding: Prototype to Production
12 lessons 路 5.5h
Vibe Coding: Multi-Agent Engineering
12 lessons 路 5.3h
Vibe Coding: Advanced Engineering
12 lessons 路 7.3h
