Skip to content

Weekly Review — Month 2 · Week 1 (Days 029–035)

Journal index · Roadmap › Month 2 Week 1

📅 The Week in One Line

Learned the standard library's I/O and text stack: the io.Reader/io.Writer interfaces, bufio buffering, os/files, fmt verbs, and the strings/strconv/bytes/strings.Builder text tools.

✅ What I Completed

  • Day 029 — io.Reader/io.Writer interfaces & io helpers (+ io-basics example)
  • Day 030 — bufio Scanner & buffered Writer (+ bufio-scan example)
  • Day 031 — os, files & exit codes
  • Day 032 — fmt verbs deep dive (+ fmt-verbs example)
  • Day 033 — strings, strconv, bytes (+ strings-strconv example)
  • Day 034 — strings.Builder & efficient concatenation
  • Day 035 — Review & closed-book recall
  • Runnable examples: 4 (io-basics, bufio-scan, fmt-verbs, strings-strconv)
  • Exercises solved: 3 (linestats, csvsum, slugify) — all with table-driven tests

💡 Lessons Learned

  • Everything is a byte stream: io.Reader/io.Writer are one-method interfaces, so files, strings, buffers, and sockets are interchangeable.
  • The Read contract: handle n bytes before err, because data and io.EOF can arrive together.
  • Two silent data-loss traps: forgetting bufio.Writer.Flush(), and os.Exit skipping deferred cleanup.
  • string(65) is "A", not "65" — use strconv for number↔text; it always returns an error, so never ignore it.
  • += in a loop is O(n²) (strings are immutable); strings.Builder makes it amortized O(n) and must never be copied by value.

💪 Strengths (what clicked)

  • fmt verbs (%v/%+v/%#v/%T, width/precision, %w) — felt natural after the example.
  • Composing io helpers (io.Copy, TeeReader, MultiWriter) into small pipelines.

🧩 Weaknesses (what's still fuzzy)

  • Writing a robust custom bufio.SplitFunc that handles tokens spanning buffer boundaries.
  • Predicting exactly when []bytestring conversions allocate vs. get optimized away.
  • When fmt.Formatter is worth implementing over a simple Stringer.

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

  1. Q: (Month 1) What's the zero value of a slice, map, and pointer?
    Anil for all three; a nil slice is safe to append to, a nil map panics on write.
  2. Q: (Month 1) Value vs pointer receiver — which can a value satisfy an interface with?
    AA value's method set includes only value-receiver methods; you need an addressable/pointer value to satisfy an interface that requires pointer-receiver methods.
  3. Q: (This week) Why must you call Flush on a bufio.Writer?
    AIt buffers writes in memory; without Flush the pending bytes never reach the underlying writer.
  4. Q: (This week) Which verb shows a value's Go-syntax form even if it has a String() method?
    A%#v.

🎯 Action Items

  • Benchmark += vs strings.Builder with testing.B + b.ReportAllocs() during Week 2 (testing).
  • Write one custom SplitFunc (e.g. split on blank-line paragraph boundaries).
  • Re-read the fmt verb table once more before tooling week.

🚀 Next Week Goals

  • Master testing: table-driven tests, subtests with t.Run, testing.B benchmarks, and coverage.
  • Learn the go toolchain: go test, go vet, gofmt/goimports, go build/run, modules.
  • Explore flag for CLI args and errors/log ergonomics.

📊 Metrics

Hours Days hit Exercises Commits Avg confidence
10.5 7/7 3 7 3.⅘

Suggested commit: docs(journal): month 2 week 1 review