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)