Describe the bug
I see this linter warning in my project which uses Go 1.22 in go.mod:
datarace: datarace: range value i is captured (by-reference) in goroutine (revive)
To Reproduce
Steps to reproduce the behavior:
Write this code:
package test
import (
"log"
"sync"
"testing"
)
func Test(t *testing.T) {
t.Parallel()
clients := []string{"a", "b", "c", "d", "e"}
wg := sync.WaitGroup{}
const one = 1
for i := range clients {
wg.Add(one)
go func() {
defer wg.Done()
log.Println(clients[i])
}()
}
wg.Wait()
}
2. Enable all rules in config:
```toml
enableAllRules = true
Run revive:
revive -config conf.toml .
Expected behavior
No warning for Go 1.22
Logs
PS C:\Users\Eldar\Projects\test> revive -config conf.toml .
a_test.go:23:24: datarace: range value i is captured (by-reference) in goroutine
a_test.go:23:24: loop variable i captured by func literal
Desktop (please complete the following information):
Describe the bug I see this linter warning in my project which uses Go 1.22 in go.mod: datarace: datarace: range value i is captured (by-reference) in goroutine (revive)
To Reproduce Steps to reproduce the behavior:
import ( "log" "sync" "testing" )
func Test(t *testing.T) { t.Parallel()
}
Expected behavior No warning for Go 1.22
Logs PS C:\Users\Eldar\Projects\test> revive -config conf.toml . a_test.go:23:24: datarace: range value i is captured (by-reference) in goroutine a_test.go:23:24: loop variable i captured by func literal
Desktop (please complete the following information):