MCPcopy Create free account
hub / github.com/cli/cli / lifetimeFromEnv

Function lifetimeFromEnv

internal/debug/config.go:48–61  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

46}
47
48func lifetimeFromEnv(name string) o.Option[time.Duration] {
49 raw, ok := os.LookupEnv(name)
50 if !ok {
51 return o.None[time.Duration]()
52 }
53 seconds, err := strconv.ParseInt(raw, 10, 64)
54 if err != nil {
55 panic(fmt.Errorf("%s: %w", name, err))
56 }
57 if seconds > math.MaxInt64/int64(time.Second) || seconds < math.MinInt64/int64(time.Second) {
58 panic(fmt.Errorf("%s: lifetime in seconds overflows time.Duration", name))
59 }
60 return o.Some(time.Duration(seconds) * time.Second)
61}

Callers 1

configFromEnvFunction · 0.85

Calls 2

DurationMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected