You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A developer can create local .env file and add it in git ignore.
He can then store environment variables for his local development there (such as secrets).
Docker out of the box supports .env file, so running in a container those are accessible via os.Getenv(). But in order for those to be accessible also in local Go set up, you can do godotenv.Load(".env") first.
If you want to avoid manual call of os.Getenv() for each environment variable + get use of default values + have some support of data types, you can create struct that would contain fields named the same way as your environment variables are named - then you pass the struct to envconfig.Process("", &environmentVariables) which enriches the instance with values via reflection.
A developer can create local .env file and add it in git ignore.
He can then store environment variables for his local development there (such as secrets).
Docker out of the box supports .env file, so running in a container those are accessible via os.Getenv(). But in order for those to be accessible also in local Go set up, you can do godotenv.Load(".env") first.
If you want to avoid manual call of os.Getenv() for each environment variable + get use of default values + have some support of data types, you can create struct that would contain fields named the same way as your environment variables are named - then you pass the struct to envconfig.Process("", &environmentVariables) which enriches the instance with values via reflection.
The text was updated successfully, but these errors were encountered: