Skip to content

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 & done channels.

📝 Notes

  • Re-ran every example with go run; ran go test -race ./exercises/month-03/... (pipeline, fanin, workerpool all green, no races).
  • Ran gofmt -l . and go vet ./... — no formatting or vet issues (no copied WaitGroup, no lost cancel).
  • Reimplemented the fan-in merge from memory (active recall) — got the close-once closer goroutine right on the second try.

🧠 Closed-Book Recall (Week 1)

  1. Q: Why must wg.Add run before the go statement?
    AAdd inside the goroutine races with Wait, which could return early on a zero counter.
  2. Q: Unbuffered vs buffered send blocking?
    AUnbuffered blocks until a receiver rendezvous; buffered blocks only when the buffer is full.
  3. Q: The four close panic cases?
    ASend on closed, close a closed, close a nil → panic; receive on closed → zero value, ok==false.
  4. Q: Send/receive on a nil channel?
    ABoth block forever — useful to disable a select case.
  5. Q: Two ready select cases — which wins?
    AOne chosen uniformly at random; no priority.
  6. Q: Deadlock vs goroutine leak?
    ADeadlock = all goroutines blocked, runtime panics; leak = program runs, some goroutines stranded, no panic.
  7. Q: Why return <-chan T from a generator?
    AReceive-only enforces that callers can't send to or close a channel the generator owns.

🐛 Mistakes / Themes This Week

  • break inside select not 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.Context as 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: sync primitives (Mutex, RWMutex, Once, atomics) and context for cancellation & deadlines.

Time spent Difficulty Confidence
75 min 🟦⬜⬜⬜⬜ 🟦🟦🟦🟦⬜

Suggested commit: docs(journal): month 3 week 1 review (day 063)