Free to read online
Learn Go with AI
Coding with a Human Mind and AI Assistance
Learn Go with AI is a book, free to read online, that teaches Go programming to beginners with an AI assistant at your side from the first page, without letting it think for you. You build one small project, an expense tracker, from a one-line program to a tested, concurrent web API, using only Go's standard library.
About the book
Ask an AI to build an expense tracker in Go, and it says "Sure!" and hands you two hundred lines of code. It might even run. But can you say what line 40 does? If it breaks next week, where would you start looking?
This book teaches you Go with an AI assistant at your side from the first page, without letting it think for you. Every chapter follows one simple loop, the SURE loop: Specify what "done" means, Use the AI, Review the code, and Explain it in your own words. The one rule: be SURE you can explain it.
You'll build Tracker, a small expense tracker that grows from a one-line program into a tested, concurrent web API, using only Go's standard library. Along the way, the AI's job grows from tutor to pair to implementer, and your judgment grows with it.
What you'll learn
- Write the tests that say what "done" means, then let the AI build to them
- Check AI-written Go with the compiler,
go vet, your tests and the race detector - Spot where AI gets Go wrong: outdated advice, money in
float64, ignored errors and data races - Learn Go's core ideas well enough to explain them: slices, maps, structs, errors, packages, interfaces, HTTP and goroutines
Read it online: table of contents
The whole book is free to read here, one page per chapter.
- IntroductionWhy learn to write Go yourself when an AI can write it in seconds? This introduction explains who the book is for, what you'll build (Tracker, a small expense tracker) and how every chapter uses the SURE loop: Specify, Use the AI, Review, Explain.
- Chapter 1: Learning to Code When AI Can CodeChapter 1 gets you from nothing to a running Go program.
- Chapter 2: Your First Program and Your First TestChapter 2 turns your spec into a Go test, so Go checks your work instead of your eyes.
- Chapter 3: Lists, Lookups and LoopsChapter 3 teaches Go's slices, maps and its one loop keyword, for.
- Chapter 4: Modeling Data and Handling ErrorsChapter 4 gives Tracker a proper shape with a struct and methods, and makes it remember your expenses in a JSON file.
- Chapter 5: Organizing Code: Packages and InterfacesChapter 5 splits Tracker into packages and introduces interfaces, with one Storage interface that has a file version and an in-memory version for tests.
- Chapter 6: From Command Line to WebChapter 6 turns Tracker into a JSON web API built on Go's standard net/http package.
- Chapter 7: A Taste of GoroutinesChapter 7 is a first taste of Go concurrency.
- Appendix A: Setting up your AI assistantAppendix A is the setup guide: installing the Go tools and putting them on your PATH, choosing an editor, installing an AI coding assistant (Claude Code in the examples) and making sure it reads your AGENTS.md rules.
- Appendix B: Just enough GitAppendix B covers only the Git you need for this book: setting it up, committing each step with a Learned: line, checking what the AI changed before and after it edits your code, and undoing changes you don't want.
- Appendix C: The SURE loop at a glanceAppendix C puts the whole method on one page: the one rule (be SURE you can explain it), the four SURE steps, the check command and how to commit.
- Appendix D: Review checklistsAppendix 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.
Stuck on an exercise? See the practice answers for Chapters 1 to 7.
Get the book
- Read online: free, every chapter, start with the Introduction.
- Kindle ebook: $0.99. Buy on Amazon
- Leanpub (PDF and EPUB): $0.99. Buy on Leanpub
- Paperback: $9.99. Buy on Amazon
Frequently asked questions
Is Go good for beginners?
Yes. Go is a small language with a short list of keywords and one loop keyword, so there's less to learn before you build something real. Its compiler gives clear error messages, and the tools you need come with it: go test for tests, gofmt for formatting and go vet for common mistakes. This book uses only Go's standard library, so there's no framework to learn first.
Can I learn Go with AI?
Yes, if the AI helps you think instead of thinking for you. Every chapter of Learn Go with AI uses the SURE loop: Specify what “done” means, Use the AI, Review the code, and Explain it in your own words. The AI starts as your tutor, becomes your pair and ends as the implementer, while you write the tests and review its code.
Is the Learn Go with AI book free?
Yes: the whole book is free to read online on this site, with every chapter and appendix on its own page. If you'd rather buy it from a store, the Kindle ebook and the Leanpub PDF and EPUB cost $0.99 and the paperback $9.99.
What do I need installed?
A computer running macOS, Windows or Linux, and an internet connection. You install Go 1.27 (Chapter 1 shows how), an editor such as Visual Studio Code with the Go extension, an AI coding assistant (the examples use Claude Code, but any assistant works) and Git. Appendix A walks through the setup.
Do I need programming experience?
No. You don't need to know Go. If you've written a little code in another language, that helps, but the book walks you through every step, starting with installing Go. It's written for junior developers and anyone newer to programming.
What will I build?
Tracker, a small expense tracker. It starts as a one-line program and grows into a tested, concurrent web API organized into packages, using only Go's standard library, with no framework and no database server.
Where are the answers to the practice exercises?
On the practice answers page: worked answers to the optional Practice exercise at the end of Chapters 1 to 7, each run on Go 1.27.4.
About the author
Roonglit Chareonsupkul is a software engineer from Bangkok, Thailand, who has been shipping production systems since 2003. He leads engineering teams as head of AI and software development, and he is the creator of Bogie.
After this book
Ready to build a real web app in Go? Bogie: How to Go from Zero to Production picks up where this one stops, with conventions, generators and a deployment to your own server.