Skip to content

Commit f45dcea

Browse files
committed
fix: capture loop variable by value in TestLockerMultipleWaiters
The loop variable `i` was captured by reference in the closure, causing all goroutines to write to `results[9]` instead of their respective indices. This fix captures the loop variable by value to ensure each goroutine uses the correct index.
1 parent 2850f91 commit f45dcea

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

internal/util/locker/locker_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ func TestLockerMultipleWaiters(t *testing.T) {
214214

215215
// Start multiple waiters
216216
for i := range numWaiters {
217+
//nolint:copyloopvar // We want to use the loop variable in the goroutine
218+
i := i
217219
wg.Go(func() {
218220
//nolint:testifylint // Using assert in goroutine per go-require rule
219221
assert.NoError(t, l.Lock(context.Background(), "test"))

0 commit comments

Comments
 (0)