Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
PIP-1490: Fix go vet errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Baliedge committed Dec 9, 2021
1 parent 03ce71a commit 54c8265
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
6 changes: 4 additions & 2 deletions gubernator_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,15 @@ func (chp *gubernatorPool) Load(ctx context.Context) error {
loadChMap := map[uint64]loadChannel{}

// Send each item to assigned channel's cache.
mainloop:
for {
var item CacheItem
var ok bool

select {
case item, ok = <-ch:
if !ok {
return nil
break mainloop
}
// Successfully received item.

Expand Down Expand Up @@ -379,14 +380,15 @@ func (chp *gubernatorPool) handleLoad(request poolLoadRequest, cache Cache) {
span, ctx := tracing.StartSpan(request.ctx)
defer span.Finish()

mainloop:
for {
var item CacheItem
var ok bool

select {
case item, ok = <-request.in:
if !ok {
return
break mainloop
}
// Successfully received item.

Expand Down
16 changes: 8 additions & 8 deletions lrucache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func BenchmarkLRUCache(b *testing.B) {
key := strconv.Itoa(i)
doneWg.Add(1)

go func() {
go func(i int) {
defer doneWg.Done()
launchWg.Wait()

Expand All @@ -429,7 +429,7 @@ func BenchmarkLRUCache(b *testing.B) {
mutex.Lock()
cache.Add(item)
mutex.Unlock()
}()
}(i)
}

b.ReportAllocs()
Expand Down Expand Up @@ -469,7 +469,7 @@ func BenchmarkLRUCache(b *testing.B) {
mutex.Unlock()
}()

go func() {
go func(i int) {
defer doneWg.Done()
launchWg.Wait()

Expand All @@ -481,7 +481,7 @@ func BenchmarkLRUCache(b *testing.B) {
mutex.Lock()
cache.Add(item)
mutex.Unlock()
}()
}(i)
}

b.ReportAllocs()
Expand All @@ -499,17 +499,17 @@ func BenchmarkLRUCache(b *testing.B) {
for i := 0; i < b.N; i++ {
doneWg.Add(2)

go func() {
go func(i int) {
defer doneWg.Done()
launchWg.Wait()

key := strconv.Itoa(i)
mutex.Lock()
_, _ = cache.GetItem(key)
mutex.Unlock()
}()
}(i)

go func() {
go func(i int) {
defer doneWg.Done()
launchWg.Wait()

Expand All @@ -522,7 +522,7 @@ func BenchmarkLRUCache(b *testing.B) {
mutex.Lock()
cache.Add(item)
mutex.Unlock()
}()
}(i)
}

b.ReportAllocs()
Expand Down
12 changes: 6 additions & 6 deletions sync_lrucache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func BenchmarkSyncLRUCache(b *testing.B) {
key := strconv.Itoa(i)
doneWg.Add(1)

go func() {
go func(i int) {
defer doneWg.Done()
launchWg.Wait()

Expand All @@ -291,7 +291,7 @@ func BenchmarkSyncLRUCache(b *testing.B) {
ExpireAt: expireAt,
}
_ = syncCache.Add(item)
}()
}(i)
}

b.ReportAllocs()
Expand Down Expand Up @@ -330,7 +330,7 @@ func BenchmarkSyncLRUCache(b *testing.B) {
_, _ = syncCache.GetItem(key)
}()

go func() {
go func(i int) {
defer doneWg.Done()
launchWg.Wait()

Expand All @@ -340,7 +340,7 @@ func BenchmarkSyncLRUCache(b *testing.B) {
ExpireAt: expireAt,
}
_ = syncCache.Add(item)
}()
}(i)
}

b.ReportAllocs()
Expand All @@ -367,7 +367,7 @@ func BenchmarkSyncLRUCache(b *testing.B) {
_, _ = syncCache.GetItem(key)
}()

go func() {
go func(i int) {
defer doneWg.Done()
launchWg.Wait()

Expand All @@ -378,7 +378,7 @@ func BenchmarkSyncLRUCache(b *testing.B) {
ExpireAt: expireAt,
}
_ = syncCache.Add(item)
}()
}(i)
}

b.ReportAllocs()
Expand Down

0 comments on commit 54c8265

Please sign in to comment.