#Python PEP 249 (peps.python.org/pep-0249/) and #Golang database/sql (pkg.go.dev/database/sql) show why DB standards matter: apps get one stable API across drivers. PEP 249 defines a shared set of exception types, so switching DBs preserves your basic error handling structure.
0
0
1
123
val, ok := m[key] // Maps
val, ok := <-ch // Channels
val, ok := i.(Type) // Assertions
val := m[key]
val := <-ch
val := i.(Type)
In #golang, the 2nd variable ok is completely optional. Use it when a ok is needed.
val, ok := <-ch // Channels
val, ok := i.(Type) // Assertions
val := m[key]
val := <-ch
val := i.(Type)
In #golang, the 2nd variable ok is completely optional. Use it when a ok is needed.
0
0
0
141
Lock() in sync.Mutex / sync.RWMutex vs RLock() in sync.RWMutex:
Lock() — blocks readers AND writers
RLock() — blocks writers only, does NOT block other readers
Use RWMutex RLock() when reads >> writes.
#golang #concurrency
Lock() — blocks readers AND writers
RLock() — blocks writers only, does NOT block other readers
Use RWMutex RLock() when reads >> writes.
#golang #concurrency
2
0
0
131
Always benchmark, but for writer starvation: "pkg.go.dev/sync#RWMutex If any goroutine calls RWMutex.Lock while the lock is already held by one or more readers, concurrent calls to RWMutex.RLock will block until the writer has acquired (and released) the lock "
0
0
0
63
sync.Once's .Do and sync.OnceFunc both take func() — no return.
So the result has to live somewhere: a separate struct field you write to as a side effect.
sync.OnceValue takes func() T — the return value IS the cache. No extra field.
#golang #concurrency
So the result has to live somewhere: a separate struct field you write to as a side effect.
sync.OnceValue takes func() T — the return value IS the cache. No extra field.
#golang #concurrency
0
0
0
86
time.After(d): Concurrency tool. Sets up a background timer and returns a channel.
t.After(u): Date/time method. Instant boolean comparison to check if timestamp t occurs after timestamp u.
#Golang time package
t.After(u): Date/time method. Instant boolean comparison to check if timestamp t occurs after timestamp u.
#Golang time package
0
0
0
89
Go proverb: “errors are values” means “errors are values that implement the `error` interface.”
#Golang
#Golang
0
0
1
59
Go's time package has two sides:
date/time handling
Timer-based concurrency tools:
time.NewTimer(d)
timer.Stop()
timer.Reset(d)
time.After(d)
time.AfterFunc(d, f)
time.NewTicker(d)
ticker.Stop()
time.Tick(d)
#golang #concurrency
date/time handling
Timer-based concurrency tools:
time.NewTimer(d)
timer.Stop()
timer.Reset(d)
time.After(d)
time.AfterFunc(d, f)
time.NewTicker(d)
ticker.Stop()
time.Tick(d)
#golang #concurrency
0
0
0
93
Go goroutine stack dumps show a bracketed state like [chan send] or [chan receive]: that means blocked. The full list lives in src/runtime/runtime2.go as waitReason constants. Not documented anywhere else. #golang
github.com/golang/go/blob…
github.com/golang/go/blob…
0
0
0
110
Check out the official list of Go replacements: pkg.go.dev/golang.org/x/t…
From Go 1.26+, `go fix` helps you with each of these replacements automatically! #golang
From Go 1.26+, `go fix` helps you with each of these replacements automatically! #golang
0
0
0
86
It’s great to see the #golang compiler using stack allocations to kill those noisy 1, 2, and 4-item heap allocations—even for escaping slices.
Optimized performance, automatically. go.dev/blog/allocatio…
become allocation aware #ziglang
Optimized performance, automatically. go.dev/blog/allocatio…
become allocation aware #ziglang
1
0
1
125
Interesting historical context on the Ruby YJIT port discussion 4 years ago.
bugs.ruby-lang.org/issues/18481 Search 'Zig'
#ZigLang
bugs.ruby-lang.org/issues/18481 Search 'Zig'
#ZigLang
0
0
0
230

