Go 101
This book teaches Go, also known as Golang, as a first programming language for beginner readers. Go is small and has few rules to learn, and its compiler points out many mistakes before the program runs. The lessons build from nothing, so there is no assumed background. The final part of the book shows how everything you learned maps to a small web server, using only the standard library.
How the book is organised
The book is split into seven parts. Each part ends with a small project that only uses the things taught up to that point, so the reader is never asked to use a feature they have not seen yet.
- Part 1. Before you write code: what programming actually is, how to plan a program on paper with flowcharts, the three patterns every program is made of. No computer needed. Skip this part if you have written code before.
- Part 2. Getting started: installing Go, running your first program, fixing your first error.
- Part 3. The basics: variables, strings, numbers, getting input from the keyboard.
- Part 4. Making decisions and repeating:
if,switch,for, the first real game. - Part 5. Data and reusable code: functions, errors, slices, maps, splitting code into packages.
- Part 6. Structs and interfaces: methods, pointers, composition, and designing your own types.
- Part 7. Bridge to the web: how the Go you just learned shows up inside a web server, plus two small web projects.
How each chapter is laid out
Each chapter has the same shape:
- A short explanation of one idea.
- Worked code examples that can be opened from the
exercises/folder and run on the reader's computer. - A few Try this prompts inside the chapter. These are one line changes meant to be answered immediately.
- A Homework section at the end with three to five problems and one optional Challenge.
- A separate homework solutions page (linked at the end of the homework section) that explains how to think about each problem, then shows a worked solution and common mistakes.
What you need
- For Part 1: just a sheet of paper and a pencil.
- For Parts 2 onwards: a computer running Windows 10 or 11, an internet connection long enough to install Go and a text editor, and a keyboard.
The next chapter starts Part 1 by asking what a program actually is. If you have written code before and want to skip ahead, the Setup chapter installs Go and your editor.