Skip to content

Glossary: Software Design Patterns in Go

Singleton

Also written: singletons

A type that allows only one instance and hands everyone that same instance. In Go a package-level variable built once with `sync.Once` does the job, but changeable shared values become global state.

Where the book teaches it

Related terms

sync.OnceGlobal mutable state