Learn Go with AI · Free online book
Appendix D: Review checklists
In short: Appendix D collects every chapter's review checklist and every 'Where AI gets Go wrong' box in one place, plus two lists for whenever the AI reviews or writes code: how to review its code and how to decide on each suggestion.
Every chapter’s Review checklist and “Where AI gets Go wrong” box, gathered in one place, plus the two lists you use whenever the AI reviews or writes code. Use it when you review your own code, or the AI’s.
The chapter sections are quoted unchanged from Chapters 1 to 7, where every command and output was run for this edition (Go 1.27.4). Inside them, words like “this chapter,” “below,” “Break 1” or “the Practice exercise,” and instructions such as “Add these two lines as the last lines of main,” refer to that chapter and its code.
Reviewing the AI’s code
- Scope:
git status --shortlists only what you asked for, never a test file. - Checks:
go run ./check, plusgo test -race ./...if goroutines share the code. - Diff:
git add ., thengit diff --staged. Read every line, including changes you didn’t ask for. - Questions: Can you explain it? Does every error path
return? Does it matchSPEC.md, including status codes? For a server, try it for real withcurl.
Deciding on a review suggestion
- Do I understand it? If you can’t explain it, you can’t keep it.
- Does it fit this project? It must follow your rules:
AGENTS.md(Go 1.27, standard library only) and the book’s Must know points, like money in cents. - Do the tests still pass? Make one change at a time and run
go test ./...after each.
Each suggestion gets one of four verdicts, the same ones the chapters’ review tables use:
- Keep: it passes all three questions.
- Your call: a real improvement, but optional. Keep it if you can explain it (and, if it changes behavior, after updating
SPEC.mdand the tests); otherwise treat it as skip for now. - Skip for now: it may well be right, but it isn’t right for you today, for example because it uses something you can’t explain yet. “Skip for now” doesn’t mean the AI was wrong.
- Reject: it breaks your rules, the book’s Must know points or a “Where AI gets Go wrong” warning, such as a third-party package, money in a
float64orlog.Fataldeep inside a function.
Chapter 5’s review table writes Skip for now as just Skip; they’re the same verdict.
Chapter 1: Learning to Code When AI Can Code
Check it yourself
Chapter 2: Your First Program and Your First Test
Check it yourself
Chapter 3: Lists, Lookups and Loops
Check it yourself
Chapter 4: Modeling Data and Handling Errors
Check it yourself
Chapter 5: Organizing Code: Packages and Interfaces
Check it yourself
Chapter 6: From Command Line to Web
Check it yourself
Chapter 7: A Taste of Goroutines
Chapter 7 has no “Check it yourself” list. Its Review checklist is the “Questions for this kind of change” from Review the AI’s work, plus the first question for the import feature:
- Is every access locked?
Addwritesexpenses, whileTotalsandSaveread it. All three must lock, not only the one that writes. Break 1 below shows why. - Does
Savehold the lock while writing the file? Yes, and that’s on purpose: it also stops two saves from writingexpenses.jsonat the same time. That’s what turned the file into broken JSON in the opening experiment. - Why is the amount check before the lock? It doesn’t touch shared data, so there’s no need to make other goroutines wait for it. Keep locked sections short.
- Is
Openstill right? It builds a newTrackerwithmuleft at its zero value, which is an unlocked mutex, ready to use. Must know #4 in action. - How many goroutines start, and does every one of them finish? Here, one per file, and each sends exactly one result. The receiving loop runs once per file, even after an error. If it returned at the first error, the remaining goroutines would wait forever to send. That’s the goroutine leak from the box.