Fix potential negative index when getting color from name

This commit is contained in:
Tulir Asokan 2019-01-12 00:44:32 +02:00
parent e539a9098c
commit d624023ca3

View File

@ -60,8 +60,8 @@ func GetHashColorName(s string) string {
return "yellow"
default:
h := fnv.New32a()
h.Write([]byte(s))
return colorNames[int(h.Sum32())%len(colorNames)]
_, _ = h.Write([]byte(s))
return colorNames[h.Sum32()%uint32(len(colorNames))]
}
}