Go.Tips
12 subscribers
7 photos
16 links
Useful tips, libraries and information for Go (Golang) developers

Rust::Tips: @rust_code_tips
My GitHub: https://github.com/ankddev
Download Telegram
Use sync.Once for Lazy Initialization
Use sync.Once to ensure a function runs only once, even in concurrent scenarios. It's perfect for lazy initialization of shared resources.
var once sync.Once
func initResource() {
fmt.Println("Initialized")
}
once.Do(initResource)

#tip #sync
@golang_tips