Go for Backend Services
A complete Go course for backend work: the toolchain, interfaces, errors as values, concurrency, HTTP services, database access and production concerns.
- Modules
- 06
- Lessons
- 18
- Reading time
- 10H 30M
- Words
- 33,574
What you will be able to do
- Write idiomatic Go that passes gofmt and go vet without argument.
- Design with structs, interfaces and errors as values instead of exceptions.
- Use goroutines, channels and context without introducing a leak or a race.
- Build an HTTP service with middleware and graceful shutdown.
- Query a database with database/sql and manage transactions correctly.
- Profile, benchmark and containerise a service for production.
Before you start
Working knowledge of at least one compiled or statically typed language, and comfort with a terminal. No prior Go required.
Go is a small language with a large standard library, and almost all of the difficulty is in the second part. The syntax takes an afternoon. Knowing when a goroutine leaks, why an interface should be defined by the consumer, or how a context cancellation propagates through four layers of a request takes considerably longer, and those are the things that decide whether a service is calm in production.
This course is written for developers who already program and want Go specifically for backend work. It covers the language in three modules and spends the other three on the parts that actually run in production: HTTP services, database access, testing, benchmarking and observability.
Every example compiles and runs. Concurrency examples are run under the race detector, because a concurrency lesson that has never been checked for races is a lesson in how to write a race.
Curriculum
6 modules, 18 lessons
Getting started with Go
The toolchain, modules, packages, gofmt and vet, and a first program you actually understand.
3 lessons · 1H 25M
Types and structure
Structs, methods, interfaces, embedding, and the error-as-value convention.
3 lessons · 1H 35M
Concurrency
Goroutines, channels, select, sync primitives, context and the race detector.
3 lessons · 1H 40M
HTTP services
Handlers, middleware, JSON encoding, routing, timeouts and graceful shutdown.
3 lessons · 1H 45M
Data and persistence
database/sql, connection pools, transactions, migrations and mapping rows.
3 lessons · 2H 05M
Production
Table tests, benchmarks, pprof, structured logging, configuration and containers.
3 lessons · 2H
Go deeper