Skip to content

Commit f1518cb

Browse files
authored
refactor: Detects type switches that can benefit from type guard clause with variable (#15)
1 parent 9b4c9b6 commit f1518cb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

color.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func Toggle(enable bool) {
5959
//
6060
// println(color.Colorize(color.Red, "This is red"))
6161
func Colorize(color string, s any) string {
62-
switch s.(type) {
62+
switch s := s.(type) {
6363
case string:
6464
if !enabled {
65-
return s.(string)
65+
return s
6666
}
67-
return color + s.(string) + Reset
67+
return color + s + Reset
6868
default:
6969
if !enabled {
7070
return fmt.Sprint(s)

0 commit comments

Comments
 (0)