Guide · Open source
How to use Learn Go with Tests: a free TDD course for Go
Updated · written with AI from the project's own documentation and checked against our catalogue data
Learn Go with Tests is a free, open book that teaches the Go programming language by having you write a test first and then the code that makes it pass. This guide explains how to get to the book, what you need before you start, and how to work through it in order. By the end you will know which chapters to read first and how the later chapters build a small HTTP application.
Quick start
- 1Check for Go. Make sure Go is installed. If it is not, use the Install Go chapter of the book.
- 2Open the book. Start with the online Gitbook edition, or download the EPUB or PDF from the releases page.
- 3Read Install Go and Hello, world. These chapters set up your environment and introduce your first test and program.
- 4Work through the fundamentals in order. Write each test first, watch it fail, then write the code that passes it.
- 5Build the HTTP application. Continue to the Build an application section, where each chapter extends the same project.
- 6Clone the repo if you want the code. Run git clone https://github.com/quii/learn-go-with-tests to get a local copy of the source.
What you need before you start
The book is a step-by-step course, so you read it in order and run the code as you go. The only prerequisite listed in the project is an installed copy of Go. The book has an Install Go chapter that covers setting up your environment.
- Go, installed on your machine (see the Install Go chapter)
- Time to work through chapters in sequence, since each one builds on the last
Read the book online, as an EPUB or as a PDF
The easiest way to start is the online version on Gitbook. If you prefer an offline copy, the project's releases page provides the book as an EPUB or PDF.
The book is also available in several other languages, including Chinese, Portuguese, Japanese, French, Korean, Turkish, Persian, Dutch, Vietnamese and Russian. Each translation is linked from the project README.
- Online: the Gitbook edition linked from the README
- Offline: the EPUB or PDF files on the project releases page
- Other languages: linked from the Translations section of the README
Get a local copy of the repository
If you want the source of the book, including the code examples, clone the repository from GitHub. The README gives this command for cloning the project.
git clone https://github.com/quii/learn-go-with-testsFollow the chapters in order
The book is split into sections. Go Fundamentals starts with Install Go and Hello, world, then covers variables, integers, iteration, arrays and slices, structs and interfaces, pointers and errors, maps, dependency injection, mocking, concurrency, generics and more.
After the fundamentals, the Build an application section walks through an HTTP server, JSON and routing, IO and sorting, the command line, time, and WebSockets. A Testing fundamentals section covers acceptance tests and working without mocks. Each application chapter extends the previous one.
- Go fundamentals: install Go, Hello world, integers, iteration, arrays and slices, structs, pointers and errors, maps, dependency injection, mocking, concurrency, generics
- Build an application: HTTP server, JSON, routing and embedding, IO and sorting, command line, time, WebSockets
- Testing fundamentals: acceptance tests, scaling acceptance tests, working without mocks, refactoring checklist
Use the Q&A chapters when you have a specific problem
The Questions and answers section contains short chapters on specific testing problems, such as running OS commands, creating custom error types, a context-aware Reader, and revisiting HTTP handlers. The author invites readers to raise new questions as GitHub issues.
- OS exec, error types, context-aware Reader, revisiting HTTP handlers
What people use it for
- Learning Go from scratch with a guided, test-first course
- Learning Go's testing style if you already know another programming language
- Introducing Go and TDD together to a development team
- Working through exercises in order and building a small HTTP application
Frequently asked questions
Is Learn Go with Tests free?
Yes. The author offers the book for free, and the project is published under the MIT licence. The README also lists optional ways to show appreciation, such as buying the author a coffee or sponsoring on GitHub, but these are not required.
What do I need to install to use Learn Go with Tests?
You need Go installed. The book has an Install Go chapter that explains how to set up your environment. You can read the book online without installing anything else.
Can I read Learn Go with Tests offline?
Yes. The project releases page provides the book as an EPUB or PDF file, which you can download and read offline.
Is Learn Go with Tests available in other languages?
Yes. The README links to translations in Chinese, Portuguese, Japanese, French, Korean, Turkish, Persian, Dutch, Vietnamese and Russian.
Is Learn Go with Tests good for experienced Go developers?
It is aimed at people who are new to Go or want a guided course. Experienced developers who only need a language reference may find the official Go docs more useful, since the book is a step-by-step course and its chapters are long.
What are the alternatives to Learn Go with Tests?
The project lists A Tour of Go and Go by Example as comparable resources, along with forks of Learn Go with Tests in other languages. The README does not compare them in detail.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Learn Go with Tests suits developers new to Go, programmers coming from another language who want Go's testing style, and teams learning Go and TDD together. If you want a quick overview or a formal language specification, pick A Tour of Go, Go by Example, or the official Go docs instead.
Install options & downloads