mirror of
https://github.com/joho/godotenv.git
synced 2025-05-31 11:42:15 +00:00
Change check of existing env to respect empty (but set) vars.
This commit is contained in:
parent
cd1272609d
commit
034acc2190
@ -119,8 +119,15 @@ func loadFile(filename string, overload bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentEnv := map[string]bool{}
|
||||||
|
rawEnv := os.Environ()
|
||||||
|
for _, rawEnvLine := range rawEnv {
|
||||||
|
key := strings.Split(rawEnvLine, "=")[0]
|
||||||
|
currentEnv[key] = true
|
||||||
|
}
|
||||||
|
|
||||||
for key, value := range envMap {
|
for key, value := range envMap {
|
||||||
if os.Getenv(key) == "" || overload {
|
if !currentEnv[key] || overload {
|
||||||
os.Setenv(key, value)
|
os.Setenv(key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user