Skip to content

Commit

Permalink
- add support for bools
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketlaunchr-cto committed Dec 17, 2019
1 parent c527d11 commit 6ce52de
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion forks/fmtless/fmtshim.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,25 @@ func getSpec(window []byte) (string, bool) {
speclen = 2
}
switch window[speclen-1] {
case 'v', 's', 'q', 'd', 'b', 'f', 'F', 'g', 'G', 'e', 'E', 'o', 'x', 'X', 'U':
case 'v', 's', 'q', 'd', 'b', 'f', 'F', 'g', 'G', 'e', 't', 'E', 'o', 'x', 'X', 'U':
return string(window[:speclen]), true
default:
return "", false
}
}

func fmtBool(spec string, i bool) string {
switch spec {
case "%s", "%t", "%v", "%#v":
if i == true {
return "true"
}
return "false"
default:
panic("Unsupported spec for bool: " + spec)
}
}

func fmtI(spec string, i interface{}) string {
switch i.(type) {
case reflect.Type:
Expand All @@ -145,6 +157,8 @@ func fmtI(spec string, i interface{}) string {
return fmtString(spec, i.(error).Error())
case string:
return fmtString(spec, i.(string))
case bool:
return fmtBool(spec, i.(bool))
case []byte:
return fmtBytes(spec, i.([]byte))
case rune:
Expand Down

0 comments on commit 6ce52de

Please sign in to comment.