Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Created January 26, 2023 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arriqaaq/d42ad479a15b37ae7f3d943731b3ed48 to your computer and use it in GitHub Desktop.
Save arriqaaq/d42ad479a15b37ae7f3d943731b3ed48 to your computer and use it in GitHub Desktop.
type Config struct {
// fields and methods
}
var config *Config
func GetConfig() *Config {
if config == nil {
config = &Config{}
}
return config
}
func main() {
GetConfig().Set("key", "value")
// It's difficult to know the state of config at this point
GetConfig().Set("key", "new_value")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment