Golang

Go language concepts, idioms, tooling and testing

Golang

Notes on Go as a technology: how it thinks, how to write it idiomatically, and how to build, test and ship it.

Page What’s in it
Philosophy & Idioms Design goals, OO without classes, idiomatic design
Types, Interfaces & Composition Structs, methods, implicit interfaces, embedding, generics, packages
Errors Errors as values, wrapping, errors.Is/As, defer, panic
Concurrency Goroutines, channels, select, context, shutdown, pitfalls
Web Services with the Standard Library net/http routing, middleware, slog, go:embed, pprof
Toolchain: Build, Check, Ship The go command, cross-compiling, static binaries, containers
Testing & Profiling Table-driven tests, fakes, testcontainers, Playwright, fuzzing, pprof
Gotchas Surprises for newcomers
OpenAPI Code Generator Generating gin server scaffolding from an OpenAPI spec

Philosophy & Idioms

What Go optimises for, how it does OO without classes, and the idioms that follow.

Types, Interfaces & Composition

Structs, methods, implicit interfaces, embedding and generics.

Errors

Errors as values: sentinels, wrapping, errors.Is/As, defer, panic and recover.

Concurrency

Goroutines, channels, select, context, mutexes and common patterns.

Web Services with the Standard Library

net/http routing, middleware, slog, go:embed, config and pprof without a framework.

Toolchain: Build, Check, Ship

The go command as build tool, formatter and linter; cross-compiling and container images.

Testing & Profiling

go test, table-driven tests, fakes, httptest, testcontainers, Playwright, benchmarks, fuzzing and pprof.

Gotchas

Things that compile fine in your head but not in Go, or compile and surprise you.

OpenAPI Code Generator

Per-tag gin server scaffolding from an OpenAPI spec using oapi-codegen and a custom splitter.