os.ReadFile replaced ioutil.ReadFile in 1.16 and is the one-liner for small files.
Category
Snippets in Systems
Fixed number of goroutines draining a channel, with the group ensuring main waits for all of them.
Cancels the request and everything downstream of it after two seconds. The defer is not optional.
? propagates the error to the caller, which is why Rust functions rarely need explicit error branches.
Filter and map fuse into a single pass; collect decides what comes out the other end.
The stream closes itself when it leaves scope, whether the function returns normally or throws.
The allocation that nobody checks is the one that fails in production.
A record plus a switch pattern removes most of the ceremony this used to take.
?. stops at the first null and ?: supplies the fallback, replacing a stack of if statements.
Runs the downloads concurrently and collects them, with cancellation propagating to all of them.
Turning the feature on makes the compiler point at every place a null could slip through.