Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package config
- import (
- "os"
- "sync"
- )
- type Config struct {
- Name string
- }
- func (c *Config) Refresh() {
- c.Name = os.Getenv("NAME")
- println("Refreshing")
- }
- var instance *Config
- var once sync.Once
- func GetConfig() *Config {
- once.Do(func() {
- println("getting config")
- instance = &Config{}
- instance.Refresh()
- })
- return instance
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement