-
Notifications
You must be signed in to change notification settings - Fork 405
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
Added global substitutions support #72
Conversation
@joho ping? |
@arsoba PTAL? |
Seconding the need for this fix. I also notice a slight tweak that I'd consider necessary: this fix does not work intuitively with the Overload() vs. Load() paradigm: Load() will not override variables defined previously in the file, but will override those inherited from os environment. The overload flag would have to be propagated to expandVariables() and the os/file value returned accordingly where this fix was made. |
Just FYI yesterday I created issue #102 and then implemented https://github.com/joho/godotenv/pull/103/files which holds the same feature here but already considering the comment @ebudan added, passing through the overload flag to the expansion function. |
@ebudan @fabriciojs I don't think we need to care about load vs overload here, that's handled after in the @joho why is a custom function needed for expanding variables? Why not just use |
if val, ok := m[submatch[4]]; ok { | ||
return val | ||
} | ||
return os.Getenv(submatch[4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return os.Getenv(submatch[4]) | |
if val, ok := os.LookupEnv(submatch[4]); ok { | |
return val | |
} |
nit: this way if the variable is not defined yet it will remain unexpanded allowing that case to be handeld by the code using this lib.
Hi,
I've added support for substitutions for global env vars.