
Large JSON Responses in Go Without Running Out of Memory
Serve a 200,000-row JSON export in Go by streaming rows from the database: first byte in 1 ms instead of 161, 1 MB of heap instead of 57, and gzip on the fly.
Everything you need to level up your coding skills.

Serve a 200,000-row JSON export in Go by streaming rows from the database: first byte in 1 ms instead of 161, 1 MB of heap instead of 57, and gzip on the fly.

Meter API usage and enforce quotas in Go: an atomic conditional UPDATE, idempotent events, weighted routes, refunds for 5xx, UTC periods and reconciliation.

How a Go API should wrap its JSON: bare resources, a data envelope for lists, empty arrays instead of null, optional totals, and why to skip a success flag.

Write JSON marshalers in Go for enums, dates, durations and Unix times: MarshalText versus MarshalJSON, clear errors, the pointer receiver trap and recursion.

Generate, store and rotate API keys in Go: a prefixed format with a checksum, SHA-256 storage, throttled last-used, overlap rotation and 85 ns rejection.

Build the sending side of webhooks in Go: signed deliveries, a retry schedule that honors Retry-After, permanent versus temporary failures and dead endpoints.

Make POST safe to retry in a Go API with an Idempotency-Key middleware: concurrent duplicates, replayed responses, payload fingerprints and 5xx handling.

Generate a typed Go client from an OpenAPI file with oapi-codegen, then wrap it: auth by request editor, Go errors from problem documents and a drift check.

Design bulk endpoints in Go: atomic versus partial modes, per-item results by index, savepoints, idempotent refs, limits, and 100 creates in 1.2 ms not 18.

Use go-playground/validator in a Go API: tags, nested rules, JSON field names in errors, and the traps around zero values, dive, panics and per-call setup.

Stream JSON in Go without loading it all: an iterator over a top-level array, NDJSON with a Decoder, element-by-element encoding and a live heap of 0.02 MB.

Rate limit a Go API per key and per route with token buckets: weighted costs, 429 with Retry-After, idle sweeping, a fake test clock and 123 ns decisions.
We send one email when a new article is published. No spam.