Tagged articles

sync.Mutex

2 articles · Page 1 of 1
Nullbody Notes
Nullbody Notes
Nov 19, 2020 · Fundamentals

Understanding the Singleton Pattern in Go: Eager vs Lazy Implementations

The article explains Go's singleton pattern, detailing eager (init) and lazy implementations using sync.Mutex and sync.Once, provides full code examples, demonstrates that each accessor returns the same instance, and discusses trade‑offs between memory usage and performance.

Design PatternGoconcurrency
0 likes · 5 min read
Understanding the Singleton Pattern in Go: Eager vs Lazy Implementations