-
Notifications
You must be signed in to change notification settings - Fork 323
FeatureRequest: ToBool add int* support #134
Copy link
Copy link
Closed
Description
Lines 81 to 99 in 8807572
| func ToBoolE(i interface{}) (bool, error) { | |
| i = indirect(i) | |
| switch b := i.(type) { | |
| case bool: | |
| return b, nil | |
| case nil: | |
| return false, nil | |
| case int: | |
| if i.(int) != 0 { | |
| return true, nil | |
| } | |
| return false, nil | |
| case string: | |
| return strconv.ParseBool(i.(string)) | |
| default: | |
| return false, fmt.Errorf("unable to cast %#v of type %T to bool", i, i) | |
| } | |
| } |
there only assert type int, no int8, int16, int32, int64, uint ...
could we add these type case?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels