Rohit Sachdeva

2.1K posts

Rohit Sachdeva banner
Rohit Sachdeva

Rohit Sachdeva

@_r_sachdeva

Senior #Golang #Go Concurrency Backend Software Engineer #Ziglang #Zig Supporting: #Ruby #Python #TypeScript ( #JavaScript ) #Rust

Dallas, TX Bergabung Eylül 2009
92 Mengikuti1.3K Pengikut
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
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.
English
0
0
0
41
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
Always benchmark, but for writer starvation: "#RWMutex" target="_blank" rel="nofollow noopener">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 "
English
0
0
0
33
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
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
English
2
0
0
52
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
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
English
0
0
0
53
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
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
English
0
0
0
75
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
Go proverb: “errors are values” means “errors are values that implement the `error` interface.” #Golang
English
0
0
1
46
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
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
English
0
0
0
83
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
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 #L1221" target="_blank" rel="nofollow noopener">github.com/golang/go/blob…
English
0
0
0
102
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
@sskras @ziglang Zig forces explicit allocation awareness, so when Go handles it automatically, it is more noticeable.
English
0
0
0
35
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
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
English
1
0
1
123
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
#golang • for {} — Header omission = true. • switch {} — Header omission = true (if/else chain). #ziglang • while (true) {} — Header requires explicit true. • if / else — Standard conditionals; switch requires expression.
English
0
0
0
114
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
Catch compile time errors in your comptime assertion blocks in tests, skip runtime test execution: `zig test --test-no-exec <file.zig>` #ZigLang #Zig
English
0
0
2
2.6K
Rohit Sachdeva
Rohit Sachdeva@_r_sachdeva·
-freference-trace[=num]: How many lines of reference trace should be shown per compile error—handy for getting more context without noisy output. #ziglang often tells you “references hidden; use -freference-trace=…” in the error message. #zig
English
0
0
0
185
Rohit Sachdeva me-retweet
Rust Language
Rust Language@rustlang·
Rust 1.85.0 has been released! 🌈🦀✨ Not only does this release add async closures, it also includes a whole new Rust Edition, Rust 2024! 🎆🚀 Check out the blog post for an overview of all the changes and additions: blog.rust-lang.org/2025/02/20/Rus…
English
22
449
1.7K
128.1K