Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit 034acc2

Browse files
committed
Change check of existing env to respect empty (but set) vars.
1 parent cd12726 commit 034acc2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

godotenv.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ func loadFile(filename string, overload bool) error {
119119
return err
120120
}
121121

122+
currentEnv := map[string]bool{}
123+
rawEnv := os.Environ()
124+
for _, rawEnvLine := range rawEnv {
125+
key := strings.Split(rawEnvLine, "=")[0]
126+
currentEnv[key] = true
127+
}
128+
122129
for key, value := range envMap {
123-
if os.Getenv(key) == "" || overload {
130+
if !currentEnv[key] || overload {
124131
os.Setenv(key, value)
125132
}
126133
}

0 commit comments

Comments
 (0)