Closed g41797 closed 1 year ago
Maybe instead of bringing another dependency the config.LoadConfig()
function could check for presence of .env
and load the AppConfig
based on those values instead of getting them from the system environment variables.
Something like:
config/config.go line:85
func LoadConfig() AppConfig {
if .env exists {
return loadFromEnvFile()
}
// load from system environement variables
}
Format of .env
is fairly straightforward to parse, maybe into a map[string]string spliting by \n
and by =
would give key, value, from there the AppConfig
could be filled with all values.
What do you think?
Now I think to add .vscode/launch.json with some default configurations will be simplest solution
Is your feature request related to a problem? Please describe. go code reads os(shell) environment variables via os.Getenv("name") API. In order to get values for development saved in .env file, path to this file should be added to json config files of IDE. Cumbersome process.
Describe the solution you'd like
Use new config.Getenv("name")
Describe alternatives you've considered Add env variables to .vscode/launch.json and save it in repository something like:
Additional context Example of godotenv usage