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
Bound Concurrency in Go With a Fixed Worker Pool Level: Advanced

Stop spawning an unbounded goroutine per job and build a fixed-size worker pool in Go with bounded channels, context cancellation, and predictable memory usage.

Go
Choose Between sync.Mutex, sync.RWMutex, and sync/atomic Level: Advanced

Compare sync.Mutex, sync.RWMutex, and sync/atomic on real read-heavy and write-heavy Go benchmarks, and see when RWMutex slows down under contention.

Go
Reuse Buffers Without Corrupting Data Using sync.Pool Level: Advanced

Cut per-request allocations with sync.Pool without leaking stale bytes across requests or holding onto oversized buffers forever.

Go
Find CPU and Heap Hotspots in Go With pprof Level: Advanced

Capture CPU and heap profiles from a Go test or net/http/pprof endpoint, read flat vs cum in go tool pprof -top, and verify that a fix actually reduced allocations.

Go
Catch Goroutine Leaks and Hanging Tests With t.Cleanup and go test -timeout Level: Advanced

Detect leaked goroutines and deadlocked channels in Go tests using runtime.NumGoroutine, t.Cleanup, and go test -timeout instead of waiting for a 10-minute CI hang.

Go
Retry Transient Failures in Go With Exponential Backoff and Jitter Level: Advanced

Build a Go retry helper that only retries 429 and 5xx errors, adds full jitter to avoid thundering herds, and respects context.Context cancellation between attempts.

Go
Recover From Panics and Cap Request Bodies in Go HTTP Middleware Level: Advanced

Keep one handler panic or one oversized JSON payload from crashing a Go API server using recover middleware and http.MaxBytesReader.

Go
Run a Go Binary in FROM scratch With CA Certificates and Non-Root User Level: Advanced

Package a static Go binary in a FROM scratch Docker image with CA certificates for outbound HTTPS calls and a non-root numeric UID so the container runs safely in production.

Go
Understand Go Pointers (& and *) Without Guessing Level: Beginner

Learn how &x and *p work in Go, why value parameters copy data, and how to guard against nil pointer dereferences. After this, pointer bugs stop being guesswork.

Go
Organize Go Modules With go mod tidy and internal/ Packages Level: Beginner

Structure a multi-package Go repository with cmd/, internal/, go get, and go mod tidy. After this, private packages cannot be imported from outside your module.

Go
Parse Flags, Env Vars, and Exit Codes in a Go CLI Level: Beginner

Build testable Go CLIs using flag.NewFlagSet, os.Getenv defaults, os.Stderr error messages, and clean integer exit codes.

Go
Write Generic Functions in Go With comparable, cmp, slices, and maps Level: Intermediate

Use type parameters with comparable and cmp.Ordered alongside Go's standard slices and maps packages. After this, you eliminate duplicate helpers without losing type safety.