Graceful shutdown for HTTP servers in Go
Safely shut down HTTP servers in Go with signal.NotifyContext and http.Server.Shutdown, handling timeouts, WebSockets, resources, and Kubernetes.
Safely shut down HTTP servers in Go with signal.NotifyContext and http.Server.Shutdown, handling timeouts, WebSockets, resources, and Kubernetes.
A guide to using encoding/json in Go, from Marshal/Unmarshal, struct tags, Encoder/Decoder to custom types, with tests and common errors.
How to build worker pools in Go using channels, sync.WaitGroup, context, and errgroup for bounded parallelism with cancellation and testing.
Go has no inheritance. This article explains struct embedding, how methods are promoted, method shadowing pitfalls, and how to combine embedding with interfaces.
Understand the mechanisms of defer, panic, recover in Go, common pitfalls, and when to return error instead of panic.
Guide to using pprof to collect and analyze CPU, heap, goroutine, block, and mutex profiles in Go applications, from HTTP services to benchmarks.
Learn how maps in Go work, why programs crash with "concurrent map writes", and how to fix it using sync.Mutex, sync.RWMutex, sync.Map.
Understand how slices share a backing array, the role of len and cap, and how to avoid hard-to-detect data corruption bugs when using append.
Guide to using Go modules for project initialization, adding and upgrading dependencies, handling major versions, replace, go.work, and private modules.
How to write table-driven tests in Go with slice structs, t.Run, error checking, parallel execution and struct comparison using go-cmp, plus common pitfalls.
Use sync.WaitGroup to wait for goroutines, sync.Mutex to avoid data races, and errgroup to collect errors, cancel with context, and limit goroutine count.
Use Go 1.22's ServeMux to match HTTP methods, read path parameters, and return JSON. You'll have a complete REST API without needing third-party routers.
Learn how to use type parameters, constraints, the ~ notation, and generic types in Go through Order, Customer, Stack, and Cache examples.
How to wrap errors with %w, check errors across the wrap chain with errors.Is, extract custom errors with errors.As, combine errors with errors.Join, and common pitfalls.
Go interfaces are implicitly satisfied. This guide shows how to keep interfaces small, declare them at the point of use, test with fakes, and avoid common pitfalls like nil interfaces.
Learn how to use context.Context in Go to control timeout, deadline, cancel goroutines, and pass request-scoped values safely.
Goroutine leaks don't crash immediately but silently consume RAM over time. This article reveals common causes, detection methods, and thorough fixes.
Learn how Go handles concurrency through goroutines and channels, from basics to practical patterns like WaitGroup, select, and context.