(envKey string, flagVal string, defaultVal string)
| 26 | } |
| 27 | |
| 28 | func getStringValue(envKey string, flagVal string, defaultVal string) string { |
| 29 | var res string |
| 30 | |
| 31 | // If defined, take the env variable |
| 32 | if _, ok := os.LookupEnv(envKey); ok { |
| 33 | res = os.Getenv(envKey) |
| 34 | } |
| 35 | |
| 36 | // If a flag is specified, this value takes precedence |
| 37 | // Ignore cases where the flag carries the default value |
| 38 | if flagVal != "" && flagVal != defaultVal { |
| 39 | res = flagVal |
| 40 | } |
| 41 | |
| 42 | // if we still don't have a value, use the default |
| 43 | if res == "" { |
| 44 | res = defaultVal |
| 45 | } |
| 46 | return res |
| 47 | } |
| 48 | |
| 49 | func getIntValue(envKey string, flagVal int, defaultVal int) int { |
| 50 | var res int |
no outgoing calls
no test coverage detected