Weekly Review — Month 2 · Week 1 (Days 029–035)¶
📅 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.Writerinterfaces & io helpers (+io-basicsexample) - Day 030 —
bufioScanner & buffered Writer (+bufio-scanexample) - Day 031 —
os, files & exit codes - Day 032 —
fmtverbs deep dive (+fmt-verbsexample) - Day 033 —
strings,strconv,bytes(+strings-strconvexample) - 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.Writerare one-method interfaces, so files, strings, buffers, and sockets are interchangeable. - The
Readcontract: handlenbytes beforeerr, because data andio.EOFcan arrive together. - Two silent data-loss traps: forgetting
bufio.Writer.Flush(), andos.Exitskipping deferred cleanup. string(65)is"A", not"65"— usestrconvfor number↔text; it always returns an error, so never ignore it.+=in a loop is O(n²) (strings are immutable);strings.Buildermakes it amortized O(n) and must never be copied by value.
💪 Strengths (what clicked)¶
fmtverbs (%v/%+v/%#v/%T, width/precision,%w) — felt natural after the example.- Composing
iohelpers (io.Copy,TeeReader,MultiWriter) into small pipelines.
🧩 Weaknesses (what's still fuzzy)¶
- Writing a robust custom
bufio.SplitFuncthat handles tokens spanning buffer boundaries. - Predicting exactly when
[]byte↔stringconversions allocate vs. get optimized away. - When
fmt.Formatteris worth implementing over a simpleStringer.
🔁 Spaced-Repetition Re-quiz (topics from earlier weeks)¶
- Q: (Month 1) What's the zero value of a slice, map, and pointer?
A
nilfor all three; anilslice is safe toappendto, anilmap panics on write. - Q: (Month 1) Value vs pointer receiver — which can a value satisfy an interface with?
A
A value's method set includes only value-receiver methods; you need an addressable/pointer value to satisfy an interface that requires pointer-receiver methods. - Q: (This week) Why must you call
Flushon abufio.Writer?A
It buffers writes in memory; withoutFlushthe pending bytes never reach the underlying writer. - Q: (This week) Which verb shows a value's Go-syntax form even if it has a
String()method?A
%#v.
🎯 Action Items¶
- Benchmark
+=vsstrings.Builderwithtesting.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 witht.Run,testing.Bbenchmarks, and coverage. - Learn the
gotoolchain:go test,go vet,gofmt/goimports,go build/run, modules. - Explore
flagfor CLI args anderrors/logergonomics.
📊 Metrics¶
| Hours | Days hit | Exercises | Commits | Avg confidence |
|---|---|---|---|---|
| 10.5 | 7/7 | 3 | 7 | 3.⅘ |
Suggested commit: docs(journal): month 2 week 1 review