diff --git a/keymutex/hashed.go b/keymutex/hashed.go index 54e28b00..3781b19a 100644 --- a/keymutex/hashed.go +++ b/keymutex/hashed.go @@ -42,17 +42,17 @@ type hashedKeyMutex struct { // Acquires a lock associated with the specified ID. func (km *hashedKeyMutex) LockKey(id string) { - km.mutexes[km.hash(id)%len(km.mutexes)].Lock() + km.mutexes[km.hash(id)%uint(len(km.mutexes))].Lock() } // Releases the lock associated with the specified ID. func (km *hashedKeyMutex) UnlockKey(id string) error { - km.mutexes[km.hash(id)%len(km.mutexes)].Unlock() + km.mutexes[km.hash(id)%uint(len(km.mutexes))].Unlock() return nil } -func (km *hashedKeyMutex) hash(id string) int { +func (km *hashedKeyMutex) hash(id string) uint { h := fnv.New32a() h.Write([]byte(id)) - return int(h.Sum32()) + return uint(h.Sum32()) }