2019-04-23 16:06:45 +03:00

35 lines
509 B
Go

package cli
import (
"os"
"strconv"
)
func getEnvString(env string, def string) string {
value := os.Getenv(env)
if value != "" {
return value
} else {
return def
}
}
func getEnvInt(env string, def string) int {
value := getEnvString(env, def)
// TODO: handle error
converted, _ := strconv.Atoi(value)
return converted
}
func getEnvBool(env string, def string) bool {
value := getEnvString(env, def)
// TODO: handle error
converted, _ := strconv.ParseBool(value)
return converted
}