
Learn Go with Tests
A free online book that teaches Go programming through test-driven development.
- Stars
- 23.9k
- Forks
- 2.9k
- Licence
- MIT
- Language
- Go
- Last update
- 11 days ago
- Type
- Learning resource
What it is
Learn Go with Tests is a free, open book that teaches the Go programming language by having you write tests first, then the code that makes them pass. It covers Go basics such as variables, slices, maps, and interfaces, then moves on to building a small HTTP application and testing topics like mocking and acceptance tests. It is available as a website, EPUB, or PDF, and has been translated into several languages.
- Work through the chapters in order to learn Go syntax and standard library basics
- Follow the Build an application section to write a small HTTP server with tests
- Use the testing fundamentals chapters to learn about fakes, acceptance tests, and refactoring
- Read the book offline using the EPUB or PDF from the releases page
Great for
- Developers who are new to Go and want a guided, hands-on tutorial
- Programmers who already know another language and want to learn Go's testing style
- Teams introducing Go and TDD together
- Readers who prefer learning by working through exercises in order
Not ideal for
- Experts who already know Go well and only need a language reference, since the book is a step-by-step course
- People who want a quick overview in minutes, since the chapters are long and build on each other
- Readers who need a complete, formal specification of the language, which the official Go docs cover better
How to get it
- 1
Read it online
You'll need: Go (installed; see the Install Go chapter)
Clone the repository
git clone https://github.com/quii/learn-go-with-tests - 2
Run it
- Open the Gitbook link or the chapters in the repo and start with Install Go
- Work through Hello, world and write your first test
- Create a small project folder and follow each chapter's code alongside the text
- Run go test after each change to see the tests pass or fail
- 3
Get the most out of it
- Read the Why unit tests chapter first to understand the TDD approach
- Follow the Build an application section in order, since each chapter builds on the last
- Try the Roman Numerals chapter to practise TDD and property-based tests
- Read the translated versions if English is not your first language
Downloads
Strengths
- Free and open source under the MIT license
- Teaches testing and TDD alongside the language rather than as an afterthought
- Available in many formats and several translations
Trade-offs
- The README describes the project as a work in progress, so coverage may be uneven or change
- Assumes some willingness to follow along and write code rather than just read
- Requires knowing how to install Go and run tests before starting
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| learn-go-with-tests (this) | 23.9k | Learning resource | beginner | 11 days ago | Developers who are new to Go and want a guided, hands-on tutorial |
| mockito | 15.5k | Library | beginner | 7 days ago | Java developers writing unit tests for classes with external dependencies |
| testify | 26.2k | Library | beginner | 18 days ago | Go developers who want more readable test assertions than the standard library provides |
| mocha | 22.9k | Library | intermediate | 5 days ago | JavaScript and Node.js developers who want automated tests for their code |
| jasmine | 15.8k | Library | beginner | 28 days ago | JavaScript developers who want a test framework with no extra dependencies |
| chromedp | 13.3k | Library | intermediate | 4 days ago | Go developers who want to automate or test web pages in code |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.