Skip to content

Commit 4a4ac3f

Browse files
CodeLingoBotbradfitz
authored andcommitted
Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <[email protected]>
1 parent 404acd9 commit 4a4ac3f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

consistenthash/consistenthash.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ func New(replicas int, fn Hash) *Map {
4444
return m
4545
}
4646

47-
// Returns true if there are no items available.
47+
// IsEmpty returns true if there are no items available.
4848
func (m *Map) IsEmpty() bool {
4949
return len(m.keys) == 0
5050
}
5151

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

64-
// Gets the closest item in the hash to the provided key.
64+
// Get gets the closest item in the hash to the provided key.
6565
func (m *Map) Get(key string) string {
6666
if m.IsEmpty() {
6767
return ""

groupcache_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func testSetup() {
7878
}))
7979
}
8080

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

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

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

0 commit comments

Comments
 (0)