Curriculum Idioms & ecosystem Common gotchas
Common gotchas
The "what bit me in code review" survival kit:
- Loop variable capture (Go 1.22+ helped, but you should still know).
- Nil interface vs nil concrete (a non-nil pointer inside an interface variable makes the interface non-nil).
- Slice aliasing — two slices sharing a backing array.
- Goroutine leaks — a goroutine waiting on a channel that nobody will ever send to.
exercises
9 ready
01
pick oneInterface nil vs concrete nil — Go's most-famous trap.
02
pick oneSlice aliasing. Pick what prints:
03
pick oneGoroutine leaks. Pick the statement that BEST
04
fill blanksFill in the keyword. Loop variable capture in
05
fill blanksType the builtin function used to FORCE a fresh backing
06
type one lineDemonstrate the FIX for the nil-interface trap.
07
type one lineDemonstrate slice aliasing. The scaffold creates
08
write a programDemonstrate the loop-variable-capture-shadow workaround.
09
write a programTheme 7.7 capstone + Module 7 capstone +