github-vet / github-vet/rangeloop-pointer-findings
pingcap/ticdc: tests/multi_source/main.go; 32 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [pingcap/ticdc](https://www.github.com/pingcap/ticdc) at [tests/multi_source/main.go](https://github.com/pingcap/ticdc/blob/8681553d891e577264a2f1da41a0a95cdf969bd3/tests/multi_source/main.go#L78-L109)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable ddlFunc used in defer or goroutine at line 100
[Click here to see the code in its original context.](https://github.com/pingcap/ticdc/blob/8681553d891e577264a2f1da41a0a95cdf969bd3/tests/multi_source/main.go#L78-L109)
Click here to show the 32 line(s) of Go which triggered the analyzer.
```go
for i, ddlFunc := range []func(context.Context, *sql.DB){
createDropSchemaDDL, truncateDDL, addDropColumnDDL,
modifyColumnDDL, addDropIndexDDL,
} {
testName := getFunctionName(ddlFunc)
log.S().Info("running ddl test: ", i, " ", testName)
var wg sync.WaitGroup
ctx, cancel := context.WithTimeout(context.Background(), runTime)
for idx, src := range srcs {
wg.Add(1)
go func(i int, s *sql.DB) {
dml(ctx, s, testName, i)
wg.Done()
}(idx, src)
}
time.Sleep(time.Millisecond)
wg.Add(1)
go func() {
ddlFunc(ctx, srcs[0])
wg.Done()
}()
wg.Wait()
time.Sleep(5 * time.Second)
cancel()
util.MustExec(srcs[0], fmt.Sprintf("create table mark.finish_mark_%d(a int primary key);", i))
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 8681553d891e577264a2f1da41a0a95cdf969bd3
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.