switch
with single case can be rewritten as if
or if-else
CRT-A0014 68 var finalText, progressString string
69 var progress int
70
71 switch action { 72 case "chats":
73 log.Infof("Chats cleanup requested by %s", user.Username)
74 allChats := db.GetAllChats()
switch
statements with a single case
can be rewritten as if-else
or if
.
Single case
switch
can be replaced by if-else
as it appears to be more
readable. This does not apply to type switch
.
switch ok {
case true:
// body
}
if ok {
// body
}