(envKey string, flagVal int, defaultVal int)
| 47 | } |
| 48 | |
| 49 | func getIntValue(envKey string, flagVal int, defaultVal int) int { |
| 50 | var res int |
| 51 | |
| 52 | // If defined, take the env variable |
| 53 | if _, ok := os.LookupEnv(envKey); ok { |
| 54 | var err error |
| 55 | res, err = strconv.Atoi(os.Getenv(envKey)) |
| 56 | if err != nil { |
| 57 | res = 0 |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // If a flag is specified, this value takes precedence |
| 62 | // Ignore cases where the flag carries the default value |
| 63 | if flagVal > 0 { |
| 64 | res = flagVal |
| 65 | } |
| 66 | |
| 67 | // if we still don't have a value, use the default |
| 68 | if res == 0 { |
| 69 | res = defaultVal |
| 70 | } |
| 71 | return res |
| 72 | } |
| 73 | |
| 74 | func getBoolValue(envKey string, flagVal bool) bool { |
| 75 | var res bool |
no outgoing calls
no test coverage detected