Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: In Parsing expandVariables return unchanged value if not exists in envMap or os-environ #135

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion godotenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,11 @@ func expandVariables(v string, m map[string]string) string {
if submatch[1] == "\\" || submatch[2] == "(" {
return submatch[0][1:]
} else if submatch[4] != "" {
return m[submatch[4]]
if _, exists := m[submatch[4]]; exists {
return m[submatch[4]]
} else if len(os.Getenv(submatch[4])) > 0 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use os.LookupEnv instead?

return os.Getenv(submatch[4])
}
}
return s
})
Expand Down