Skip to content

Instantly share code, notes, and snippets.

@ilyabrin
Created November 29, 2015 00:57
Show Gist options
  • Select an option

  • Save ilyabrin/f4f58d640e0309a4b46e to your computer and use it in GitHub Desktop.

Select an option

Save ilyabrin/f4f58d640e0309a4b46e to your computer and use it in GitHub Desktop.
Golang singleton pattern
package singleton
type singleton struct {} // private
var instance *singleton // private
// public method GetInstance
func GetInstance() *singleton {
if instance == nil {
instance = &singleton{}
}
return instance
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment