Skip to content

Commit

Permalink
Fix function comments based on best practices from Effective Go
Browse files Browse the repository at this point in the history
Signed-off-by: CodeLingo Bot <[email protected]>
  • Loading branch information
CodeLingoBot authored and bradfitz committed Oct 25, 2019
1 parent 404acd9 commit 4a4ac3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions consistenthash/consistenthash.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func New(replicas int, fn Hash) *Map {
return m
}

// Returns true if there are no items available.
// IsEmpty returns true if there are no items available.
func (m *Map) IsEmpty() bool {
return len(m.keys) == 0
}

// Adds some keys to the hash.
// Add adds some keys to the hash.
func (m *Map) Add(keys ...string) {
for _, key := range keys {
for i := 0; i < m.replicas; i++ {
Expand All @@ -61,7 +61,7 @@ func (m *Map) Add(keys ...string) {
sort.Ints(m.keys)
}

// Gets the closest item in the hash to the provided key.
// Get gets the closest item in the hash to the provided key.
func (m *Map) Get(key string) string {
if m.IsEmpty() {
return ""
Expand Down
6 changes: 3 additions & 3 deletions groupcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func testSetup() {
}))
}

// tests that a Getter's Get method is only called once with two
// TestGetDupSuppressString tests that a Getter's Get method is only called once with two
// outstanding callers. This is the string variant.
func TestGetDupSuppressString(t *testing.T) {
once.Do(testSetup)
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestGetDupSuppressString(t *testing.T) {
}
}

// tests that a Getter's Get method is only called once with two
// TestGetDupSuppressProto tests that a Getter's Get method is only called once with two
// outstanding callers. This is the proto variant.
func TestGetDupSuppressProto(t *testing.T) {
once.Do(testSetup)
Expand Down Expand Up @@ -249,7 +249,7 @@ func (p fakePeers) PickPeer(key string) (peer ProtoGetter, ok bool) {
return p[n], p[n] != nil
}

// tests that peers (virtual, in-process) are hit, and how much.
// TestPeers tests that peers (virtual, in-process) are hit, and how much.
func TestPeers(t *testing.T) {
once.Do(testSetup)
rand.Seed(123)
Expand Down

0 comments on commit 4a4ac3f

Please sign in to comment.