Golang patterns: Revision history

From wikinotes

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

1 August 2022

22 July 2022

  • curprev 16:2416:24, 22 July 2022Will talk contribs 501 bytes +501 Created page with "Some design pattern implementations in go = Singleton = <blockquote> <syntaxhighlight lang="go"> // src: https://medium.com/golang-issue/how-singleton-pattern-works-with-golang-2fdd61cd5a7f var once sync.Once // type global type singleton map[string]string var ( instance singleton ) func NewClass() singleton { once.Do(func() { // <-- atomic, does not allow repeating instance = make(singleton) // <-- thread safe }) return instance } </syntaxhighlight> </blo..."