From 5ba99cd3651f304e3fd79cce4f05f1e6499f5307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 22 Aug 2024 23:07:00 +0200 Subject: [PATCH] Use for range-over-integers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- docker/docker_image_src.go | 2 +- pkg/blobinfocache/internal/test/test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/docker_image_src.go b/docker/docker_image_src.go index c8f6ba305..c73bd6cdf 100644 --- a/docker/docker_image_src.go +++ b/docker/docker_image_src.go @@ -830,7 +830,7 @@ func makeBufferedNetworkReader(stream io.ReadCloser, nBuffers, bufferSize uint) handleBufferedNetworkReader(&br) }() - for i := uint(0); i < nBuffers; i++ { + for range nBuffers { b := bufferedNetworkReaderBuffer{ data: make([]byte, bufferSize), } diff --git a/pkg/blobinfocache/internal/test/test.go b/pkg/blobinfocache/internal/test/test.go index cb4a4e6b0..df7136591 100644 --- a/pkg/blobinfocache/internal/test/test.go +++ b/pkg/blobinfocache/internal/test/test.go @@ -87,7 +87,7 @@ func testGenericUncompressedDigest(t *testing.T, cache blobinfocache.BlobInfoCac } func testGenericRecordDigestUncompressedPair(t *testing.T, cache blobinfocache.BlobInfoCache2) { - for i := 0; i < 2; i++ { // Record the same data twice to ensure redundant writes don’t break things. + for range 2 { // Record the same data twice to ensure redundant writes don’t break things. // Known compressed→uncompressed mapping cache.RecordDigestUncompressedPair(digestCompressedA, digestUncompressed) assert.Equal(t, digestUncompressed, cache.UncompressedDigest(digestCompressedA)) @@ -113,7 +113,7 @@ func testGenericUncompressedDigestForTOC(t *testing.T, cache blobinfocache.BlobI } func testGenericRecordTOCUncompressedPair(t *testing.T, cache blobinfocache.BlobInfoCache2) { - for i := 0; i < 2; i++ { // Record the same data twice to ensure redundant writes don’t break things. + for range 2 { // Record the same data twice to ensure redundant writes don’t break things. // Known TOC→uncompressed mapping cache.RecordTOCUncompressedPair(digestCompressedA, digestUncompressed) assert.Equal(t, digestUncompressed, cache.UncompressedDigestForTOC(digestCompressedA)) @@ -125,7 +125,7 @@ func testGenericRecordTOCUncompressedPair(t *testing.T, cache blobinfocache.Blob func testGenericRecordKnownLocations(t *testing.T, cache blobinfocache.BlobInfoCache2) { transport := mocks.NameImageTransport("==BlobInfocache transport mock") - for i := 0; i < 2; i++ { // Record the same data twice to ensure redundant writes don’t break things. + for range 2 { // Record the same data twice to ensure redundant writes don’t break things. for _, scopeName := range []string{"A", "B"} { // Run the test in two different scopes to verify they don't affect each other. scope := types.BICTransportScope{Opaque: scopeName} for _, digest := range []digest.Digest{digestCompressedA, digestCompressedB} { // Two different digests should not affect each other either.