github-vet / github-vet/rangeloop-pointer-findings
lovesgg/orange_message_service: app/services/client/client.go; 21 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [lovesgg/orange_message_service](https://www.github.com/lovesgg/orange_message_service) at [app/services/client/client.go](https://github.com/lovesgg/orange_message_service/blob/49e502a55dcd454fe5c5c2c652518d1db89bd514/app/services/client/client.go#L96-L116)
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 body used in defer or goroutine at line 102
[Click here to see the code in its original context.](https://github.com/lovesgg/orange_message_service/blob/49e502a55dcd454fe5c5c2c652518d1db89bd514/app/services/client/client.go#L96-L116)
Click here to show the 21 line(s) of Go which triggered the analyzer.
```go
for _, body := range req.Body {
go func() {
fmt.Println("sync start..............................")
postData := make(map[string]interface{})
postData["msg_key"] = req.MsgKey
postData["source_id"] = req.SourceId
postData["body"] = body
mcqKey := body.UserId + body.OrderNo; //mcq的key
fmt.Println(mcqKey)
fmt.Println(enum.MCQ_MESSAGE_CLIENT_CENTER)
fmt.Println("开始发送mq")
//执行mq发送 由server端来消费 现在这方法是模拟生产消费同步调用的。需要您自己搭建mq服务发送topic然后/server/send来消费
//关于这部分过程的调用请看根目录下的.doc目下的图片哈.这么调用也可发送。就是显得很冗余。因为加了层http调用了。你要是觉得调内网这部分耗时可忽略那就这么用吧
ret := sendMqTest(postData)
fmt.Println(ret)
//sendMq(postData) //生产环境先实现这方法
wg.Done()
}()
}
```
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: 49e502a55dcd454fe5c5c2c652518d1db89bd514
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.