Golang
7 posts
Understanding HTTP/1.1: Redirects in Go (Part 3)
301 vs 302 vs 307 vs 308 — which HTTP redirect to use, which ones browsers cache, which preserve the request method, tested against a small Go server.
Understanding HTTP/1.1: Content-Type in Go (Part 2)
How the Content-Type header decides what a browser does with your response, plus a hand-rolled http.ResponseWriter implementation in Go.
Understanding HTTP/1.1: TCP Server in Go (Part 1)
Build a raw TCP server in Go, inspect what curl and a browser actually send over the wire, and hand-craft a valid HTTP/1.1 response.
Structured Logging in Go with log/slog
Getting started with log/slog, Go 1.21's standard-library structured logger — levels, handlers, wrapping the logger, writing to a file, and go vet gotchas.
Trace Logging in Golang
Add a TRACE log level to a Go program to observe code execution paths, using runtime caller info to report the file and line that logged.
Signal Handling and Graceful Shutdown in Go
Catch SIGINT and SIGTERM in Go, broadcast the shutdown to every goroutine, unblock blocking calls and shut down an HTTP server cleanly.
Symmetric Encryption with ChaCha20-Poly1305 in Go
A practical guide to authenticated symmetric encryption in Go using ChaCha20-Poly1305 — keys, nonces, where to store them, and full working code.