Weekly Review — Month 1 · Week 2 (Days 008–014)¶
📅 The Week in One Line¶
Got fluent with Go's composite types — slices (and their backing-array gotchas), maps/sets, strings/runes, and structs with tags.
✅ What I Completed¶
- Day 008 — Arrays & slice basics (len/cap)
- Day 009 — Slice internals: backing array, append & aliasing
- Day 010 — Slice tricks: filter, insert, delete, copy
- Day 011 — Maps & sets, comma-ok, ordered iteration
- Day 012 — Strings, runes, bytes & UTF-8
- Day 013 — Structs & struct tags
- Day 014 — Review & closed-book recall
- Examples: slice-internals, slice-tricks, maps-sets, strings-runes, structs-tags
- Exercises solved: 3 (wordfreq, dedup, runereverse) — all with table-driven tests
💡 Lessons Learned¶
- A slice is a
(pointer, len, cap)view; arrays are copied values. appendwrites in place when capacity allows (aliasing!) and reallocates when it doesn't — alwayss = append(s, …).- The 3-index slice
s[i:j:j]andcopy/makeare the tools to break aliasing. - comma-ok separates "missing key" from "zero value"; writing a nil map panics.
- Map iteration is randomized — sort keys for deterministic output.
- Strings are immutable UTF-8 bytes: index → byte,
range→ rune; reverse by[]rune. - Pointer receivers mutate; value receivers copy. Struct tags drive
encoding/json, and only exported fields are serialized.
💪 Strengths (what clicked)¶
- Maps/sets and the comma-ok idiom felt natural immediately.
- Table-driven tests are now a reflex for every exercise.
🧩 Weaknesses (what's still fuzzy)¶
- Predicting cap growth and reasoning about aliasing under nested appends.
- Remembering to reach for the
slices/mapsstdlib helpers instead of hand-rolling.
🔁 Spaced-Repetition Re-quiz (topics from earlier weeks)¶
- Q: (Wk1) Why is
string(65)"A"and not"65"?A
It converts an int to a rune/code point; usestrconv.Itoafor digits. - Q: (Wk1)
deferorder and arg-evaluation timing?A
LIFO; arguments are evaluated at thedeferstatement. - Q: (Wk2) When does
appendreallocate the backing array?A
When capacity is exhausted; otherwise it writes in place and may alias other slices. - Q: (Wk2) Zero value of a map, and what happens if you write to it?
A
nil; writing to a nil map panics —makeit first.
🎯 Action Items¶
- Refactor the slice exercises to use
slices.Delete/slices.Cloneand compare. - Re-read the slices cheatsheet before Week 3.
- Add one Exercism "strings" exercise for extra rune/byte reps.
🚀 Next Week Goals¶
- Methods & receivers (value vs pointer), interfaces (implicit satisfaction, method sets, the nil-interface trap), and idiomatic error handling (
%w,errors.Is/As).
📊 Metrics¶
| Hours | Days hit | Exercises | Commits | Avg confidence |
|---|---|---|---|---|
| 10 | 7/7 | 3 | 7 | 3.⅘ |
Suggested commit: docs(journal): week 2 review