Created
January 26, 2023 07:56
-
-
Save arriqaaq/d42ad479a15b37ae7f3d943731b3ed48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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