forked from coop-cloud-mirrors/godotenv
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
|
||||
}
|
||||
|
||||
currentEnv := map[string]bool{}
|
||||
rawEnv := os.Environ()
|
||||
for _, rawEnvLine := range rawEnv {
|
||||
key := strings.Split(rawEnvLine, "=")[0]
|
||||
currentEnv[key] = true
|
||||
}
|
||||
|
||||
for key, value := range envMap {
|
||||
if os.Getenv(key) == "" || overload {
|
||||
if !currentEnv[key] || overload {
|
||||
os.Setenv(key, value)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user