github-vet / github-vet/rangeloop-pointer-findings
leekzhu/wok-go-neo4j: app/neox.go; 19 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [leekzhu/wok-go-neo4j](https://www.github.com/leekzhu/wok-go-neo4j) at [app/neox.go](https://github.com/leekzhu/wok-go-neo4j/blob/efd8d4a1dec7e2258395de688c171a9b06687846/app/neox.go#L65-L83)
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 query used in defer or goroutine at line 73
[Click here to see the code in its original context.](https://github.com/leekzhu/wok-go-neo4j/blob/efd8d4a1dec7e2258395de688c171a9b06687846/app/neox.go#L65-L83)
Click here to show the 19 line(s) of Go which triggered the analyzer.
```go
for _, query := range queries {
// Note: we pass an copy of query to runSingleQuery,
// not the address of it, otherwise the following goroutines will
// get uncertain query since they all have the same address.
// Therefore all the result information should be retrieved
// from QueryResult rather than QueryRequest
go func() {
result := QueryResult{}
result.Result = query.Result
query.Query.Result = result.Result
err := db.Cypher(query.Query.CypherQuery)
if err != nil {
panic("Err in runSingleQuery: " + err.Error())
}
result.Name = query.Name
result.Columns = query.Query.Columns()
ch <- result
}()
}
```
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: efd8d4a1dec7e2258395de688c171a9b06687846
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.