Day 014 — Week 2 Review Day¶
Month 1 · Week 2 · ⬅ Day 013 · Day 015 ➡ · Journal index
📋 Full structured review:
week-2-review.md
🎯 Learning Objective¶
Consolidate Week 2 (composite types) via closed-book recall and clean up the week's code.
📚 Topics¶
- Recap: arrays/slices (len/cap), append & aliasing, slice tricks, maps/sets, strings/runes, structs & tags.
📝 Notes¶
- Re-ran every Week 2 example with
go run; rango test ./...(wordfreq, dedup, runereverse all green). - Ran
gofmt -l .andgo vet ./...— formatting clean, no vet findings. - Redid the dedup and rune-reverse exercises from memory (active recall) — passed first try.
🧠 Closed-Book Recall (Week 2)¶
- Q: What does a slice header contain?
A
Pointer to backing array, length, capacity.
2. Q: When does append reallocate? A
When capacity is exhausted; otherwise it writes in place into the shared backing array.
3. Q: How do you cap a slice's capacity to prevent aliasing? A
The 3-index slice s[low:high:max], e.g. s[i:j:j].
4. Q: Order-preserving delete of index i? A
s = append(s[:i], s[i+1:]...).
5. Q: Reading a missing map key gives you what? A
The value type's zero value; use comma-ok to detect absence.
6. Q: Why is map iteration order randomized? A
Intentionally, so code can't depend on it; sort keys for stable output.
7. Q: Bytes vs runes for len("héllo")? A
len = 6 bytes; 5 runes.
8. Q: What does json:"-" do on a field? A
Excludes it from JSON entirely (never marshaled/unmarshaled).
🐛 Mistakes / Themes This Week¶
- The append aliasing trap (Day 009) — the week's biggest gotcha.
- Nil-map writes panicking (Day 011).
- Reversing strings by byte instead of rune (Day 012).
🪶 Feynman Reflection¶
Composite types are all about views over memory: slices view arrays, maps key-address values, strings are byte ribbons, and structs bundle fields. Knowing what is shared vs copied is the whole game.
🕳️ Knowledge Gaps Carried Forward¶
- The
slices/mapsstdlib helper packages — adopt actively next week. - Methods, interfaces, and the nil-interface trap (Week 3 headline).
✅ Summary¶
Week 2 composite types consolidated; all code formatted, vetted, and tested. Confidence on slices/maps/strings/structs now ⅘.
⏭️ Next Steps¶
- Week 3: methods & receivers, interfaces (implicit satisfaction, nil-interface trap), and error handling.
| Time spent | Difficulty | Confidence |
|---|---|---|
| 75 min | 🟦⬜⬜⬜⬜ | 🟦🟦🟦🟦⬜ |
Suggested commit: docs(journal): week 2 review (day 014)