github-vet / github-vet/rangeloop-pointer-findings
toptang/sidekick-tmatrix: logic/api/okexapi/okex.go; 10 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [toptang/sidekick-tmatrix](https://www.github.com/toptang/sidekick-tmatrix) at [logic/api/okexapi/okex.go](https://github.com/toptang/sidekick-tmatrix/blob/789796aa3e6b10f39fdda71afee7b97851cfbf17/logic/api/okexapi/okex.go#L217-L226)
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 cli used in defer or goroutine at line 220
[Click here to see the code in its original context.](https://github.com/toptang/sidekick-tmatrix/blob/789796aa3e6b10f39fdda71afee7b97851cfbf17/logic/api/okexapi/okex.go#L217-L226)
Click here to show the 10 line(s) of Go which triggered the analyzer.
```go
for _, cli := range cliLst {
log.DEBUGF("[okexapi]send to client: %v", cli)
go func(buf []byte) {
_, err := cli.Conn.Write(buf)
if err != nil {
//TODO remove client
log.ERRORF("[okexapi_sub] send data to client error: %v, addr: %s, contract: %s, table: %s, type: %s, depth: %d, period: %s", err, cli.RemoteAddr, this.Symbol, this.Table, this.Type, depth, period)
}
}(pushBuf)
}
```
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: 789796aa3e6b10f39fdda71afee7b97851cfbf17
Contributor guide
No contributing guide indexed for this repository
Research direction
Read logic/api/okexapi/okex.go at lines 217-226 and inspect how the goroutine uses the range variable cli. Check whether the reported capture can send to the wrong client, then classify the finding with the requested reaction; done means the behavior is judged Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100