How does one implement the Singleton design pattern in the go programming language?
The best approach will be:
package singleton import "sync" type singleton struct { } var instance *singleton var once sync.Once func GetInstance() *singleton { once.Do(func() { instance = &singleton{} }) return instance }
You should read this Link