adding ParseBool function
This commit is contained in:
parent
8dd2012c27
commit
2ce9bf7eff
11
settings.go
11
settings.go
@ -161,3 +161,14 @@ func NewSettingsWithContext(ctx context.Context, filename string, logUpdates boo
|
|||||||
go settings.maintenanceRoutine(ctx)
|
go settings.maintenanceRoutine(ctx)
|
||||||
return settings
|
return settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ParseBool(value string) (bool, error) {
|
||||||
|
switch strings.ToLower(strings.TrimSpace(value)) {
|
||||||
|
case "1", "true", "t", "yes", "y", "on":
|
||||||
|
return true, nil
|
||||||
|
case "0", "false", "f", "no", "n", "off":
|
||||||
|
return false, nil
|
||||||
|
default:
|
||||||
|
return false, fmt.Errorf("cannot parse '%s' as bool", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user