-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for fallback if env variable is missing #111
Comments
@lesichkovm, I think there is a similar logic provided already. When you call the Load(filenames ...string) or Overload(filenames ...string), it first calls on filenamesOrDefault(filenames); If "filenames" is empty, a fallback is provided. This fallback expects to find ".env" file in the root folder. |
@D-sense it is not about loading files, but a helper function to check if an environmental variable exists:
|
@lesichkovm , please ignore the tagging of the PR. It was a mistake (I didn’t mean to tag it here). On the point you raised, except I still haven’t gotten your point well enough, I think the existing logic already caters for that need (as outlined in my earlier response). I might be wrong though. |
If I understand @lesichkovm correctly he would like to have a function which simplifies the following:
Instead of the above code you could write this:
|
Would be nice if there was option for fallback option if a variable is missing
Something similar to:
func env(key, fallback string) string {
value, exists := os.LookupEnv(key)
if !exists {
value = fallback
}
return value
}
The text was updated successfully, but these errors were encountered: