Skip to content

Weekly Review — Month 1 · Week 2 (Days 008–014)

Journal index · Roadmap › Week 2

📅 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.
  • append writes in place when capacity allows (aliasing!) and reallocates when it doesn't — always s = append(s, …).
  • The 3-index slice s[i:j:j] and copy/make are 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/maps stdlib helpers instead of hand-rolling.

🔁 Spaced-Repetition Re-quiz (topics from earlier weeks)

  1. Q: (Wk1) Why is string(65) "A" and not "65"?
    AIt converts an int to a rune/code point; use strconv.Itoa for digits.
  2. Q: (Wk1) defer order and arg-evaluation timing?
    ALIFO; arguments are evaluated at the defer statement.
  3. Q: (Wk2) When does append reallocate the backing array?
    AWhen capacity is exhausted; otherwise it writes in place and may alias other slices.
  4. Q: (Wk2) Zero value of a map, and what happens if you write to it?
    Anil; writing to a nil map panics — make it first.

🎯 Action Items

  • Refactor the slice exercises to use slices.Delete/slices.Clone and 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