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 one
Interface nil vs concrete nil — Go's most-famous trap.
02
pick one
Slice aliasing. Pick what prints:
03
pick one
Goroutine leaks. Pick the statement that BEST
04
fill blanks
Fill in the keyword. Loop variable capture in
05
fill blanks
Type the builtin function used to FORCE a fresh backing
06
type one line
Demonstrate the FIX for the nil-interface trap.
07
type one line
Demonstrate slice aliasing. The scaffold creates
08
write a program
Demonstrate the loop-variable-capture-shadow workaround.
09
write a program
Theme 7.7 capstone + Module 7 capstone +