4 ms·
Why incur the cost and complexity of a channel if what you are doing doesn't require it? Go's sync.Once just implements the check-lock-check pattern. It doesn't
by ffk 11y ago
Why incur the cost and complexity of a channel if what you are doing doesn't require it? Go's sync.Once just implements the check-lock-check pattern. It doesn't use a channel in the background.
In fact, it is better to use sync.Once to reduce the risk getting the semantics of check-lock-check incorrect. :)
[edit: It occurred to me that the parent may be speaking about architecture and not about the singleton's design. From an architectural perspective, there are much better patterns in golang than a singleton.]
- tptacek 11y agoThe architecture! Not the design of this singleton.