You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
make go helper for "parsed string or fallback value" pattern #20018
We have this pattern of "parse string S as type T, but return a fallback value V if parsing fails" all over the place for common T types like bool, time.Duration, etc. In case a util helper doesn't exist already, we should make one and make it discoverable.
func defDuration(a string, def time.Duration) time.Duration {
if a == "" {
return def
}
v, err := time.ParseDuration(a)
if err != nil {
return def
}
return v
}
Thanks to @ibobgunardi for doing the first half in #20022. There are a second set of helpers that need to be pulled into util/def that take in keys to os.Getenv:
Activity
util/def: new package providing def.Bool and def.Duration
util/def: add functions that provide defaults for envvars
util: add parse fallback helpers (#20022)
util/def: add functions that provide defaults for envvars
sfllaw commentedon Jun 19, 2026
Thanks to @ibobgunardi for doing the first half in #20022. There are a second set of helpers that need to be pulled into util/def that take in keys to os.Getenv:
tailscale/cmd/containerboot/settings.go
Lines 497 to 506 in 5ef3713
util: add env default parse helpers
cmd/containerboot: simplify env var parsing
util/def: add Int and Float64 default parse helpers
util/def: add Int and Float64 default parse helpers
cmd/containerboot: simplify env var parsing
util/def,cmd/containerboot: add LookupEnv, simplify env parsing
util/def,cmd/containerboot: add LookupEnv, simplify env parsing
util/def,cmd/containerboot: add LookupEnv, simplify env parsing
util/def,cmd/containerboot: add LookupEnv, simplify env parsing
util/def,cmd/containerboot: add LookupEnv, simplify env parsing (#20277)
sfllaw commentedon Jul 18, 2026
Thanks to @nicholasrossi0530 for finishing the second half of this task in #20277.
I think we can close this as completed.
util: add parse fallback helpers (tailscale#20022)
util/def,cmd/containerboot: add LookupEnv, simplify env parsing (tail…