`log/slog` (Go 1.21+) is the standard structured logger. Drop-in replacement for `log` with key/value attributes and JSON output for log-pipeline ingestion.
Construct complex objects step-by-step with `self`-returning methods. Type-state can enforce required vs. optional fields at compile time — but the simple version is plenty for most cases.
Use PHP's built-in finfo (libmagic) to detect a file's true MIME type from its bytes — not from the extension, which can be lied about. Critical for validating user uploads.
Channels are typed pipes between goroutines. Unbuffered = synchronous handoff; buffered = up to N values queued. Close a channel to signal "no more values" — receivers see ok=false.
Compose's three fundamental layouts. `Column` stacks vertically, `Row` horizontally, `Box` overlays. Combine with `Modifier.weight()`, alignment, and arrangement for flexible UIs.
Set-style ops on collections. `distinct` removes duplicates; `distinctBy` lets you key the dedupe by a derived value; `union/intersect/subtract` give you set operations.
Group a list into a record keyed by whatever the callback returns. Like Lodash _.groupBy or the new Object.groupBy in modern runtimes. Generic enough to handle string, number, or symbol keys.
A search input usually has a visible-only icon — but screen readers need a real label. Pair a visually-hidden `<label>` with the icon, OR use `aria-label` on the input.
`LIMIT N OFFSET M` is universal — but degrades on deep pages (the DB still has to scan past M rows). Keyset (cursor) pagination is much faster for huge tables.
`<optgroup label="...">` visually groups options inside a `<select>`. Renders as a non-selectable header in every browser; screen readers announce the group as context.
`encoding/csv` parses RFC 4180 CSVs. Read row-by-row with `Read()` or all at once with `ReadAll()`. Same for writing — flush with `Writer.Flush()` before closing.
Go Struct Embedding (Composition over Inheritance)
Go has no inheritance. Embed a type to "promote" its fields and methods as if they were on the outer type. Same effect as inheritance for most purposes, but explicit.
Use `find -print0` + `read -d ""` to safely iterate filenames that may contain spaces, newlines, or quotes. Standard bash for-loop over `find` output breaks on these.