Day 063 — Week 1 Review Day¶
Month 3 · Week 1 · ⬅ Day 062 · Day 064 ➡ · Journal index
📋 Full structured review:
week-1-review.md
🎯 Learning Objective¶
Consolidate Week 1 of concurrency via closed-book recall and re-run all the week's code under the race detector.
📚 Topics¶
- Recap: goroutines &
WaitGroup, unbuffered vs buffered channels, the channel axioms,select/time.After, deadlocks & leaks, generators &donechannels.
📝 Notes¶
- Re-ran every example with
go run; rango test -race ./exercises/month-03/...(pipeline, fanin, workerpool all green, no races). - Ran
gofmt -l .andgo vet ./...— no formatting or vet issues (no copiedWaitGroup, no lost cancel). - Reimplemented the fan-in
mergefrom memory (active recall) — got the close-once closer goroutine right on the second try.
🧠 Closed-Book Recall (Week 1)¶
- Q: Why must
wg.Addrun before thegostatement?A
Addinside the goroutine races withWait, which could return early on a zero counter. - Q: Unbuffered vs buffered send blocking?
A
Unbuffered blocks until a receiver rendezvous; buffered blocks only when the buffer is full. - Q: The four
closepanic cases?A
Send on closed, close a closed, close a nil → panic; receive on closed → zero value,ok==false. - Q: Send/receive on a
nilchannel?A
Both block forever — useful to disable aselectcase. - Q: Two ready
selectcases — which wins?A
One chosen uniformly at random; no priority. - Q: Deadlock vs goroutine leak?
A
Deadlock = all goroutines blocked, runtime panics; leak = program runs, some goroutines stranded, no panic. - Q: Why return
<-chan Tfrom a generator?A
Receive-only enforces that callers can't send to or close a channel the generator owns.
🐛 Mistakes / Themes This Week¶
breakinsideselectnot leaving the loop (Day 060) — needed a label.- Double-closing a fan-in output (Day 062) — close belongs in one closer goroutine.
- Ranging over an unclosed channel → deadlock (Day 061).
🪶 Feynman Reflection¶
I can now structure concurrent work: launch it with go, join it with a WaitGroup, have goroutines communicate over channels, multiplex with select, bound it with timeouts, and shut it down cleanly with a done channel — without leaking or deadlocking.
🕳️ Knowledge Gaps Carried Forward¶
context.Contextas the real-world cancellation API (next week).sync.Mutex/RWMutex/atomics vs channels — when to share memory safely (next week).
✅ Summary¶
Week 1 concurrency fundamentals consolidated; all examples and exercises formatted, vetted, and -race-clean. Confidence on goroutines/channels now ⅘.
⏭️ Next Steps¶
- Week 2:
syncprimitives (Mutex,RWMutex,Once, atomics) andcontextfor cancellation & deadlines.
| Time spent | Difficulty | Confidence |
|---|---|---|
| 75 min | 🟦⬜⬜⬜⬜ | 🟦🟦🟦🟦⬜ |
Suggested commit: docs(journal): month 3 week 1 review (day 063)