Skip to content

Commit b78ccf3

Browse files
authored
style: Special case IntOrBool 1 and 0 values to yes and no. (#117)
1 parent 65be7a4 commit b78ccf3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

keepsorted/options.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,14 @@ func formatValue(val reflect.Value) (string, error) {
233233
case reflect.TypeFor[map[string]bool]():
234234
return formatList(slices.Sorted(maps.Keys(val.Interface().(map[string]bool))))
235235
case reflect.TypeFor[IntOrBool]():
236-
return strconv.Itoa(int(val.Int())), nil
236+
switch i := int(val.Int()); i {
237+
case 0:
238+
return boolString[false], nil
239+
case 1:
240+
return boolString[true], nil
241+
default:
242+
return strconv.Itoa(i), nil
243+
}
237244
case reflect.TypeFor[int]():
238245
return strconv.Itoa(int(val.Int())), nil
239246
case reflect.TypeFor[[]ByRegexOption]():

0 commit comments

Comments
 (0)