-
Notifications
You must be signed in to change notification settings - Fork 399
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
Read()
default behaviour works more like Overload
than Load()
#37
Comments
I'm thinking that it's nearly time for a v2 - I've got a couple of issues representing drift from the reference implementation that I'm not sure I can address with the current API. Do you think it would be more worthwhile to adapt the behaviour of |
Documenting the difference is certainly preferable to leaving it open to misinterpretation as an immediate measure :) As for what to do in v2, I'm not sure. I would also suspect that functions named |
I just implemented godotenv and went mental about my services doing exactly the opposite of what they were supposed to...I seriously think you should add some big bold notes about this somewhere; there's so much explanation as to why godotenv does not override keys, but then there's this mixup still. Or am I missing sth.? I could open a PR, but it seems you have some larger overhaul in mind? |
Yup, just stumbled upon this issue as well. In my opinion this should be considered a bug and fixed when it was first found out. The function is documented as The correct implementation should look like: for key, value := range individualEnvMap {
- envMap[key] = value
+ if _, ok := envMap[key]; !ok {
+ envMap[key] = value
+ }
}
|
When reading a series of files to a map, successive
.env
files which define a variable already set by files earlier in the list will overwrite the value of that variable. Since this is different from the behaviour ofLoad()
(which is consistent withLoad()
from the reference dotenv ruby implementation), this difference should be documented.Here's a gist for demonstration purposes
The text was updated successfully, but these errors were encountered: