mirror of https://github.com/joho/godotenv.git
Add values to the envMap when reading the file.
But do not override values in the global environment.pull/8/head
parent
a01a834e16
commit
dc9cc93c4e
|
@ -104,7 +104,9 @@ func loadFile(filename string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range envMap {
|
for key, value := range envMap {
|
||||||
os.Setenv(key, value)
|
if os.Getenv(key) == "" {
|
||||||
|
os.Setenv(key, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -129,7 +131,7 @@ func readFile(filename string) (envMap map[string]string, err error) {
|
||||||
if !isIgnoredLine(fullLine) {
|
if !isIgnoredLine(fullLine) {
|
||||||
key, value, err := parseLine(fullLine)
|
key, value, err := parseLine(fullLine)
|
||||||
|
|
||||||
if err == nil && os.Getenv(key) == "" {
|
if err == nil {
|
||||||
envMap[key] = value
|
envMap[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue