Skip to content

Commit

Permalink
develop add EnvBool function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolpakov committed Dec 19, 2019
1 parent bb84e28 commit 64d6228
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions configo.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ func EnvInt(key string, defaultValue int) int {
return defaultValue
}

func EnvBool(key string, defaultValue bool) bool {
if value, ok := getEnv(key); ok {
i, err := strconv.ParseBool(value)
if err == nil {
return i
}
}

return defaultValue
}

func getEnv(key string) (string, bool) {
value, ok := ConfigVariables[key]
if ok {
Expand Down

0 comments on commit 64d6228

Please sign in to comment.