Go from the ground up
Simple code that runs at scale
- Beginner
- 12 chapters
- 184 min read
Learn Go by running it: values and types, slices and maps, structs with methods, interfaces, errors as values, pointers and text, goroutines and channels, packages and tests, generics, and a worker pool that uses the whole language at once.
What You'll Learn
- Write and run a Go program, and read what the compiler refuses
- Make variables two ways, and know every value starts at its zero value
- Write functions that return several values, and loop with the one for keyword
- Keep data in slices and maps, and use comma-ok to tell absent from empty
- Model things with structs, and pick the right receiver for the method
- Describe behaviour with small interfaces and satisfy them implicitly
- Return, wrap and inspect errors instead of throwing them
- Use pointers where Go actually does, and treat text as bytes and runes
- Start goroutines, move values on channels, and wait without guessing
- Arrange a project into packages and modules, with tests beside the code
- Write generic functions and types with constraints that mean something
- Build a worker pool: jobs in, results out, and no shared memory to guard
Prerequisites
- No Go at all — the course starts at package main
- Any experience with one other language makes the first chapters quicker, but none is assumed
Course Content
- 01Your first Go programNot started
What Go is for, the three lines every program starts with, and a first run — on the server here, or with the go command on your own machine.
- 02Values, types and zero valuesNot started
Making variables two ways, the small set of built-in types, the value every variable starts with, and why Go never converts a type behind your back.
- 03Functions and control flowNot started
Functions that give back more than one value, the single for loop that covers every repetition, switch without fall-through, and defer — Go's way of saying "when this function ends".
- 04Slices and mapsNot started
The two collections every Go program uses: a slice is a growable list, a map is a lookup by key, and both of them have one behaviour worth learning exactly.
- 05Structs and methodsNot started
Making your own types out of fields, hanging functions off them, and the one distinction that matters: a method that works on a copy, and a method that works on the real thing.
- 06InterfacesNot started
Behaviour described as a set of methods, satisfied without ever saying so, and the small interfaces that keep Go code easy to swap and easy to test.
- 07Errors as valuesNot started
Errors are ordinary values that travel beside results, wrapped with context as they move up, and compared with the tools that understand wrapping.
- 08Pointers, and text done properlyNot started
What a pointer actually is — an address, not a mystery — why Go uses them in exactly two places, and how text really works: bytes, runes and the builder that avoids a copy per line.
- 09Goroutines and channelsNot started
Starting work that runs at the same time, sending values between the parts instead of sharing them, and the two tools for waiting: a WaitGroup and a closing channel.
- 10Packages, modules and testsNot started
How a Go project is arranged on disk, what the capital letter on a name means, and the test style the whole language uses: a table of cases, one loop, no framework.
- 11GenericsNot started
Writing one function for many types without giving up the types: type parameters, constraints that say what T can do, and knowing when a plain interface is still the better answer.
- 12Putting it together: a worker poolNot started
A capstone program that uses the whole course at once — structs and methods, an interface, errors as values, a pool of goroutines and channels to collect their work.
