godotenv
godotenv copied to clipboard
Added global substitutions support
Hi, I've added support for substitutions for global env vars.
@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 loadFile function.
@joho why is a custom function needed for expanding variables? Why not just use os.ExpandEnv? If the reason is to support the $(VAR) format, I think there's a (\))? missing at the end of the regex.