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:
Ville Vesilehto
2025-05-29 03:50:55 +03:00
committed by GitHub
parent b3acbe5046
commit 19a6ae4983
47 changed files with 82 additions and 81 deletions

View File

@@ -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)
}