Skip to content

Commit

Permalink
Merge pull request #8 from calavera/add_values_to_envmap
Browse files Browse the repository at this point in the history
Fix issue reading file.
  • Loading branch information
joho committed Jan 2, 2015
2 parents a01a834 + dc9cc93 commit ead2e75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions godotenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ func loadFile(filename string) (err error) {
}

for key, value := range envMap {
os.Setenv(key, value)
if os.Getenv(key) == "" {
os.Setenv(key, value)
}
}

return
Expand All @@ -129,7 +131,7 @@ func readFile(filename string) (envMap map[string]string, err error) {
if !isIgnoredLine(fullLine) {
key, value, err := parseLine(fullLine)

if err == nil && os.Getenv(key) == "" {
if err == nil {
envMap[key] = value
}
}
Expand Down

0 comments on commit ead2e75

Please sign in to comment.