(env string, defaultValue int)
| 7 | ) |
| 8 | |
| 9 | func GetEnvOrDefault(env string, defaultValue int) int { |
| 10 | if env == "" || os.Getenv(env) == "" { |
| 11 | return defaultValue |
| 12 | } |
| 13 | num, err := strconv.Atoi(os.Getenv(env)) |
| 14 | if err != nil { |
| 15 | SysError(fmt.Sprintf("failed to parse %s: %s, using default value: %d", env, err.Error(), defaultValue)) |
| 16 | return defaultValue |
| 17 | } |
| 18 | return num |
| 19 | } |
| 20 | |
| 21 | func GetEnvOrDefaultString(env string, defaultValue string) string { |
| 22 | if env == "" || os.Getenv(env) == "" { |
no test coverage detected