Concept Explanation
This lesson is a syntax workout for early Go code. The goal is not to build something large, but to get used to writing valid declarations, imports, function bodies, and simple output without fighting the compiler. You will practice noticing the small details Go cares about, such as braces, unused imports, and clear formatting, so the language starts to feel predictable instead of strict.
Where to Put the Code
- Define color and position variables at the top.
- Create shape drawing or placement logic in the middle.
- Render output (print, canvas, SVG, or styled block) at the end.
Command Reference
- Use `gofmt -w main.go` to format your file and get used to standard Go style.
- Run `go run main.go` after every small change so syntax mistakes are easier to spot.
- Pay attention to compiler messages about unused variables or imports; they are often very direct.
- Keep declarations simple: name a value, give it a clear purpose, then print or use it immediately.
Step-by-step Guide
- Run the starter code once so you know the baseline output before changing anything.
- Add a third variable, such as a boolean or short text value, and print it clearly.
- Break the code on purpose with a small syntax mistake, then fix it after reading the error.
- Format the file with `gofmt` and compare the result with your original spacing.
- End by summarizing one syntax rule that Go enforced during the exercise.
Practice Exercises
- Create a short program with one string, one number, and one boolean, then print all three.
- Write a small output block that labels each value so the terminal result is easy to read.
- Replace the starter variables with your own and keep the program compiling cleanly.
Coding Challenges
- Write the same output in a slightly different order and explain which version feels clearer.
- Trigger and fix two common beginner issues: an unused variable and a missing brace.
Mini Practice Tasks
- Run `gofmt` on the file.
- Add one new variable and print it.
- State one compiler rule that helped you catch a mistake.
Common Mistake
Mixing x and y axes or using wrong coordinate origin causes shapes to appear in unexpected places.
Real-life Mini Challenge
Draw one square, one triangle, and one circle, then move X marker 2 steps right and 1 step down.