Automate the Boring Stuff with Go
Introducing Automate the Boring Stuff with Go
The beginner-friendly guide to programming with Go. No prior experience is required.
Welcome to the free book for beginners who want to learn Go
If you’re new to Go and new to programming, there are not many books for you. Most Go books expect some programming experience and head straight for web servers and distributed systems.
Ask around in the Go communities online and you’ll hear “just do the tour”, or “build something”, or the worst one, “Go is so easy you can learn it in a day”. For a beginner that is not helpful, and it is discouraging.
Automate the Boring Stuff with Go starts from setting up your computer, teaches the language in seven short chapters, and then spends thirteen chapters building programs that take real work off your plate: spreadsheets, PDFs, files, the web, schedules, email, images, a database, a command-line tool you can ship to a friend, and a model that runs on your own machine. Every example and project is a file you can run from the book’s repository.
The 2026 edition
The book first appeared in 2022 and 2023, one chapter at a time, for Go 1.19. In October 2026 every chapter was brought up to Go 1.27, nine chapters were added, and Part 0 was written for readers starting from nothing. What changed:
- Setup and toolchain. One official installer per operating system, modules from your first program,
go run .,go vet, nothing about GOPATH. - Libraries that are still maintained. Excel on excelize, PDFs on pdfcpu, browsers on chromedp. The libraries the first edition used are archived.
- Every project rewritten. The projects in chapters 7 to 11 are new code in one consistent shape: errors returned and wrapped, HTTP with timeouts, inputs next to the code, outputs ignored by git, and a test beside every project. The code quoted in each chapter is the file in the repo, and every output shown is from a real run.
- Language features from the last four years. Error wrapping, type parameters, the
slicesandmapspackages,minandmax,rangeover an integer,math/rand/v2,log/slog. - Nine new chapters. CSV and JSON; time, scheduling and running programs; concurrency; testing and debugging; command-line tools and shipping binaries; email and notifications; images; SQLite; and automating with a model that runs on your own machine.
- Open licence. The code is MIT-licensed, so you can copy any of it into your own programs.
If you read the first edition, Part 0, chapters 6, 8 and 12 to 20 are where the new material is.
One chapter from the Python original is deliberately missing: controlling the mouse and keyboard. The Go libraries for it need a C toolchain and behave differently on every operating system, which is the opposite of what this book promises. Everything else those scripts did, you can do from the other chapters.
Contents
Part 0. Before you code
- Chapter 0.1. The terminal
- Chapter 0.2. Files, folders and paths
- Chapter 0.3. git in an afternoon
- Chapter 0.4. GitHub
Part I. All you need to get going
- Chapter 1. Setting up your developer environment
- Chapter 2. Go basics
- Chapter 3. Control flow
- Chapter 4. Functions
- Chapter 5. Slices
- Chapter 6. Maps and structs
- Chapter 7. Strings and regular expressions
Part II. Ready, set, Go
- Chapter 8. Files
- Chapter 9. Excel files
- Chapter 10. PDFs
- Chapter 11. Web requests
- Chapter 12. CSV and JSON
- Chapter 13. Time, scheduling and running programs
- Chapter 14. Concurrency
- Chapter 15. Testing and debugging
- Chapter 16. Command-line tools and shipping binaries
Part III. Further afield
- Chapter 17. Email and notifications
- Chapter 18. Images
- Chapter 19. SQLite
- Chapter 20. Automate with a local model
What you need
A computer running Windows, macOS or Linux. Nothing else. If you have never opened a terminal or used git, start with Part 0: four short chapters that teach the terminal, paths, git and GitHub from nothing, and end with you sending your first change to this book’s code. If you have, start at chapter 1, which installs Go and an editor. Everything else in the book is Go’s standard library or a package go get fetches for you. Three chapters need one more thing, and each says exactly how to get it when you reach it: chapter 11 uses Chrome for one project, chapter 17 needs an email account only if you want to really send (the dry run and the tests need none), and chapter 20 installs a small language model that runs on your own machine (about 1 GB of disk and 8 GB of memory).
How to read it
Type the code in rather than pasting it; muscle memory is most of learning a language. When something does not work, run the same file from the repository (go run ./ch3/projects/GuessTheNumber), and if it still does not work on your machine, open an issue there. The book stays free and online, and the old address, automatetheboringstuffwithgo.com, now brings you here.
So, without further ado: new to the terminal, begin with Chapter 0.1. The terminal; otherwise, Chapter 1. Setting up your developer environment.