From 0f2c13e065f95e77d4220b7d25a7844f5ea94274 Mon Sep 17 00:00:00 2001 From: Doug Collier <540588+doucol@users.noreply.github.com> Date: Thu, 17 Jul 2025 10:04:24 -0500 Subject: [PATCH] fix ChanSendEmpty loops --- internal/util/chan.go | 8 ++++---- internal/util/chan_test.go | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/util/chan.go b/internal/util/chan.go index de11e2f..a144e3a 100644 --- a/internal/util/chan.go +++ b/internal/util/chan.go @@ -1,10 +1,10 @@ package util func ChanSendEmpty[T any](ch chan T, count int) { - for range count { - var val T - ch <- val - } + for i := 0; i < count; i++ { + var val T + ch <- val + } } func ChanClose[T any](ch ...chan T) { diff --git a/internal/util/chan_test.go b/internal/util/chan_test.go index 8d9ca6e..c398a87 100644 --- a/internal/util/chan_test.go +++ b/internal/util/chan_test.go @@ -35,15 +35,15 @@ func TestChanSendEmpty(t *testing.T) { // Check if the correct number of values were sent received := 0 - for range tt.count { - select { - case <-ch: - received++ - case <-time.After(100 * time.Millisecond): - t.Errorf("Timeout waiting for value") - return - } - } + for i := 0; i < tt.count; i++ { + select { + case <-ch: + received++ + case <-time.After(100 * time.Millisecond): + t.Errorf("Timeout waiting for value") + return + } + } if received != tt.expected { t.Errorf("ChanSendEmpty() sent %v values; want %v", received, tt.expected)