Menu

#Stdlib

9 posts

Feed·
9 of 9 posts
sync.OnceFunc, OnceValue, OnceValues: When Each Beats sync.Once
🖼️
0Read More

sync.OnceFunc, OnceValue, OnceValues: When Each Beats sync.Once

DEV Community·Gabriel Anhaia·6 months ago
#LC3Cy0Cn
#concurrency#go#stdlib#once#sync

Go 1.21's sync.OnceFunc / OnceValue / OnceValues vs sync.Once. When each is the cleanest, the error-return trap, init patterns.

15s
context.WithoutCancel: When You Need Work That Outlives Its Caller
🖼️
0Read More

context.WithoutCancel: When You Need Work That Outlives Its Caller

DEV Community·Gabriel Anhaia·6 months ago
#YAXGzgdR
#go#concurrency#stdlib#backend#context

context.WithoutCancel keeps work alive past caller cancellation while keeping context values. Pattern, the deadline trap, and where Background fails.

15s
The maps Stdlib in Go 1.21+: 8 Functions That Replace Half Your Map Helpers
🖼️
0Read More

The maps Stdlib in Go 1.21+: 8 Functions That Replace Half Your Map Helpers

DEV Community·Gabriel Anhaia·6 months ago
#DbH9IB7c
#go#stdlib#generics#backend#maps

Go's maps stdlib package: 8 functions that delete handwritten helpers. Keys/Values/Clone/Copy/DeleteFunc/Equal + the iter.Seq trap.

15s
Go's cmp.Or and cmp.Compare: Three-Way Comparison Without the Boilerplate
🖼️
0Read More

Go's cmp.Or and cmp.Compare: Three-Way Comparison Without the Boilerplate

DEV Community·Gabriel Anhaia·6 months ago
#eIfvUDqb
#pattern#go#programming#stdlib#compare

Go 1.21 and 1.22 killed two ugly patterns: nested-if sort comparators and arrow-shaped fallback chains. Here's the migration.

15s
Go's slices Package: 11 Functions That Replace Half Your Helpers
🖼️
0Read More

Go's slices Package: 11 Functions That Replace Half Your Helpers

DEV Community·Gabriel Anhaia·6 months ago
#UFTdj5qV
#go#programming#stdlib#software#slices

Every Go codebase carries a folder of slice helpers written before Go 1.21. Here are the 11 stdlib functions that delete most of them.

15s