Browse Source

if/else -> switch

esell 1 year ago
parent
commit
570c217b74
1 changed files with 6 additions and 11 deletions
  1. 6
    11
      main.go

+ 6
- 11
main.go View File

@@ -163,21 +163,16 @@ func httpErrorf(w http.ResponseWriter, format string, a ...interface{}) {
163 163
 
164 164
 func statusColor(coveragePct string) string {
165 165
 	pctInt := toInt(coveragePct)
166
-
167
-	if pctInt <= 30 {
166
+	switch {
167
+	case pctInt <= 30:
168 168
 		return "red"
169
-	}
170
-
171
-	if pctInt > 30 && pctInt <= 75 {
169
+	case pctInt > 30 && pctInt <= 75:
172 170
 		return "yellow"
173
-	}
174
-
175
-	if pctInt > 75 {
171
+	case pctInt > 75:
176 172
 		return "green"
173
+	default:
174
+		return "blue"
177 175
 	}
178
-
179
-	return "blue"
180
-
181 176
 }
182 177
 
183 178
 func uploadHandler(config conf) http.Handler {