Skip to content

Commit

Permalink
refactor: use nil slice declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksezer committed Nov 9, 2022
1 parent a375452 commit 57446c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions consistent.go
Expand Up @@ -62,7 +62,7 @@ import (
)

var (
//ErrInsufficientMemberCount represents an error which means there are not enough members to complete the task.
// ErrInsufficientMemberCount represents an error which means there are not enough members to complete the task.
ErrInsufficientMemberCount = errors.New("insufficient member count")

// ErrMemberNotFound represents an error which means requested member could not be found in consistent hash ring.
Expand Down Expand Up @@ -308,15 +308,15 @@ func (c *Consistent) getClosestN(partID, count int) ([]Member, error) {
c.mu.RLock()
defer c.mu.RUnlock()

res := []Member{}
var res []Member
if count > len(c.members) {
return res, ErrInsufficientMemberCount
}

var ownerKey uint64
owner := c.getPartitionOwner(partID)
// Hash and sort all the names.
keys := []uint64{}
var keys []uint64
kmems := make(map[uint64]*Member)
for name, member := range c.members {
key := c.hasher.Sum64([]byte(name))
Expand Down

0 comments on commit 57446c9

Please sign in to comment.