From 9f6ff22cfff829561052f5886ec80a2ac148b4eb Mon Sep 17 00:00:00 2001 From: Patrick Mylund Nielsen Date: Sun, 27 May 2018 00:33:50 -0400 Subject: [PATCH] Fix benchmark for-loop shadowing --- cache_test.go | 6 +++--- sharded_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cache_test.go b/cache_test.go index 47a3d53..cb80b38 100644 --- a/cache_test.go +++ b/cache_test.go @@ -1563,12 +1563,12 @@ func benchmarkCacheGetManyConcurrent(b *testing.B, exp time.Duration) { wg := new(sync.WaitGroup) wg.Add(n) for _, v := range keys { - go func() { + go func(k string) { for j := 0; j < each; j++ { - tc.Get(v) + tc.Get(k) } wg.Done() - }() + }(v) } b.StartTimer() wg.Wait() diff --git a/sharded_test.go b/sharded_test.go index aef8597..4bc26dd 100644 --- a/sharded_test.go +++ b/sharded_test.go @@ -73,12 +73,12 @@ func benchmarkShardedCacheGetManyConcurrent(b *testing.B, exp time.Duration) { wg := new(sync.WaitGroup) wg.Add(n) for _, v := range keys { - go func() { + go func(k string) { for j := 0; j < each; j++ { - tsc.Get(v) + tsc.Get(k) } wg.Done() - }() + }(v) } b.StartTimer() wg.Wait()