I'm trying to load the environment variable with calling godotenv.Load
in my main
method but the problem is that I have init
functions in other packages and they run before the environment variables are loaded from .env file, therefore causing trouble.
Is there any workaround for this?
envconfig
that initializes a struct based on the environment variables. Are these modules all redundant? It seems then the only option isos.Getenv
- Mohsen Kamranienvconfig
? I do not quite get what you're asking for. - kostixgithub.com/kelseyhightower/envconfig
? If yes, I still don't get what you're asking for.envconfig
is a tool for "mass-application" of the values of environment variables to fields of structs—nothing more; that is, it can spare you writing a bit of boilerplate code and internally it surely callsos.Getenv
or the like. But this is not concerned with how these environment variables are set because env. vars are supposed to be set before a program which reads them actually starts. - kostix