mirror of https://github.com/joho/godotenv.git
Change check of existing env to respect empty (but set) vars.
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…
Reference in New Issue