mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 16:54:15 -04:00
lint: enable intrange linter (#7331)
Enable intrange linter to enforce modern Go range syntax over traditional for loops, by converting: for i := 0; i < n; i++ to: for i := range n Adding type conversions where needed for compatibility with existing uint64 parameters. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
10
plugin/pkg/cache/cache_test.go
vendored
10
plugin/pkg/cache/cache_test.go
vendored
@@ -13,10 +13,10 @@ func TestCacheAddAndGet(t *testing.T) {
|
||||
t.Fatal("Failed to find inserted record")
|
||||
}
|
||||
|
||||
for i := 0; i < N; i++ {
|
||||
for i := range N {
|
||||
c.Add(uint64(i), 1)
|
||||
}
|
||||
for i := 0; i < N; i++ {
|
||||
for i := range N {
|
||||
c.Add(uint64(i), 1)
|
||||
if c.Len() != N {
|
||||
t.Fatal("A item was unnecessarily evicted from the cache")
|
||||
@@ -45,7 +45,7 @@ func TestCacheLen(t *testing.T) {
|
||||
|
||||
func TestCacheSharding(t *testing.T) {
|
||||
c := New(shardSize)
|
||||
for i := 0; i < shardSize*2; i++ {
|
||||
for i := range shardSize * 2 {
|
||||
c.Add(uint64(i), 1)
|
||||
}
|
||||
for i, s := range c.shards {
|
||||
@@ -58,7 +58,7 @@ func TestCacheSharding(t *testing.T) {
|
||||
func TestCacheWalk(t *testing.T) {
|
||||
c := New(10)
|
||||
exp := make([]int, 10*2)
|
||||
for i := 0; i < 10*2; i++ {
|
||||
for i := range 10 * 2 {
|
||||
c.Add(uint64(i), 1)
|
||||
exp[i] = 1
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func BenchmarkCache(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
c := New(4)
|
||||
for n := 0; n < b.N; n++ {
|
||||
for range b.N {
|
||||
c.Add(1, 1)
|
||||
c.Get(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user