getEnvAs parses a TASK_ prefixed env var as type T
(envKey string)
| 331 | |
| 332 | // getEnvAs parses a TASK_ prefixed env var as type T |
| 333 | func getEnvAs[T any](envKey string) (T, bool) { |
| 334 | var zero T |
| 335 | switch any(zero).(type) { |
| 336 | case bool: |
| 337 | if val, ok := env.GetTaskEnvBool(envKey); ok { |
| 338 | return any(val).(T), true |
| 339 | } |
| 340 | case int: |
| 341 | if val, ok := env.GetTaskEnvInt(envKey); ok { |
| 342 | return any(val).(T), true |
| 343 | } |
| 344 | case time.Duration: |
| 345 | if val, ok := env.GetTaskEnvDuration(envKey); ok { |
| 346 | return any(val).(T), true |
| 347 | } |
| 348 | case string: |
| 349 | if val, ok := env.GetTaskEnvString(envKey); ok { |
| 350 | return any(val).(T), true |
| 351 | } |
| 352 | case []string: |
| 353 | if val, ok := env.GetTaskEnvStringSlice(envKey); ok { |
| 354 | return any(val).(T), true |
| 355 | } |
| 356 | } |
| 357 | return zero, false |
| 358 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…