in walkthroughs/howto-timeout-policy/src/colorgateway/main.go [91:109]
func getRatios() map[string]float64 {
counts := make(map[string]int)
var total = 0
for _, c := range colors {
if c != "" {
counts[c] += 1
total += 1
}
}
ratios := make(map[string]float64)
for k, v := range counts {
ratio := float64(v) / float64(total)
ratios[k] = math.Round(ratio*100) / 100
}
return ratios
}