Skip to content

Commit

Permalink
Support parsing bool config values
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jun 8, 2021
1 parent 4529324 commit 3c5ed6f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ func ConfigValue(v interface{}, dst interface{}) error {
return fmt.Errorf("unhandled type %+v for string conversion", reflect.TypeOf(vt))
}

case *bool:
switch vt := v.(type) {
case bool:
*d = vt
case string:
b, _ := strconv.ParseBool(vt)
*d = b
case int64:
*d = vt > 0
default:
return fmt.Errorf("unhandled type %+v for bool conversion", reflect.TypeOf(vt))
}

case *int64:
switch vt := v.(type) {
case int64:
Expand Down

0 comments on commit 3c5ed6f

Please sign in to comment.