Canonical guidance

Use when

Avoid

Preferred pattern

var loadConfig = sync.OnceValue(func() Config {
	return readConfig()
})

Anti-pattern

Explanation: This anti-pattern is tempting because it looks cheap, but it is exactly the kind of publication bug sync.Once exists to avoid.

Why

Related pages

Sources