type Example struct{} var doOnce sync.Once var INSTANCE *Example func NewExample() *Example { doOnce.Do(func() { INSTANCE = &Example{} }) return INSTANCE }