Skip to Content
Skip to content
PROGRAMMING

Go Tutorials

Standalone Go tutorials covering concrete runtime traps and service patterns: slice backing-array aliasing, nil-map panics, typed-nil interfaces, context.Context timeouts, worker pools, go test -race data races, pprof allocations, and static binaries under 10 MB.

Each guide pairs a small runnable Go program with its exact compiler, test, or benchmark output so you can verify the behavior locally.

Go
Why a Typed Nil Pointer Is Not == nil in Go Interfaces Level: Intermediate

Reproduce Go's typed-nil interface trap with custom errors and io.Writer, see why w == nil returns false, and fix return paths cleanly.

Go
Replace fmt.Println With Structured JSON Logging in Go (log/slog) Level: Intermediate

Switch from fmt.Println to log/slog JSON logs, attach request-scoped attributes with With, redact secrets using LogValuer, and change log levels at runtime.

Go
Stop Goroutine Leaks With select, close(ch), and ctx.Done() Level: Intermediate

Prevent blocked producer and consumer goroutines from leaking forever by closing channels on the sender side and selecting on ctx.Done().

Go
Write Clean Go Tests With Interface Fakes, t.TempDir, and testdata Level: Intermediate

Replace external dependencies with small consumer-side interface fakes, use t.TempDir() for scratch files, and load fixtures from testdata/.