在单例模式中,singleton 结构体的字段为空,多次赋值 instance 值都是一样的

作者: joengtou创建于 2024年1月29日更新于 2024年1月29日

The following code verifies that the result of multiple assignments to an empty structure is the same, in the singleton pattern, golang-design-pattern/03_singleton/singleton.go line23, even without using sync.Once, unit tests can be passed. A field should be added to singleton.

内容来源: senghoo/golang-design-pattern