随笔记录
Go语言实现单例
2025-3-10 diaba
type Example struct{}

var doOnce sync.Once
var INSTANCE *Example

func NewExample() *Example {
doOnce.Do(func() {
INSTANCE = &Example{}
})
return INSTANCE
}
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容