github-vet / github-vet/rangeloop-pointer-findings
MarkCL/currencyBot: facebookMessage.go; 22 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [MarkCL/currencyBot](https://www.github.com/MarkCL/currencyBot) at [facebookMessage.go](https://github.com/MarkCL/currencyBot/blob/bdc7e21ba073967bc1f418b6ae1731a31982b7b5/facebookMessage.go#L18-L39)
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 event used in defer or goroutine at line 24
[Click here to see the code in its original context.](https://github.com/MarkCL/currencyBot/blob/bdc7e21ba073967bc1f418b6ae1731a31982b7b5/facebookMessage.go#L18-L39)
Click here to show the 22 line(s) of Go which triggered the analyzer.
```go
for _, event := range entry.Messaging {
if !reflect.DeepEqual(event.Message, Message{}) {
_, validUser := userTargetData[event.Sender.ID]
if !invalidUserPool[event.Sender.ID] || event.Message.Text == TestTicket || validUser {
go func() {
if validUser {
if userTargetData[event.Sender.ID].UsedApiTimes < (FacebookMaxApiTimes - 1) {
FacebookSendTextMessage(ProcessReplyMessage(event.Sender.ID, event.Message.Text, true).(*bytes.Buffer))
} else if userTargetData[event.Sender.ID].UsedApiTimes == (FacebookMaxApiTimes - 1) {
FacebookSendTextMessage(ConvertStringToResponseBytes(event.Sender.ID, "超過單一小時最大訊息數(將於下一個小時恢復服務)\nExceed Max Time in this hour.(will recover service from begging of next hour.)"))
}
if userTargetData[event.Sender.ID].UsedApiTimes <= (FacebookMaxApiTimes - 1) {
userTargetData[event.Sender.ID].UsedApiTimes += 1
//fmt.Println("UsedApiTimes", userTargetData[event.Sender.ID].UsedApiTimes)
}
}else{
FacebookSendTextMessage(ProcessReplyMessage(event.Sender.ID, event.Message.Text, true).(*bytes.Buffer))
}
}()
}
}
}
```
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: bdc7e21ba073967bc1f418b6ae1731a31982b7b5
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.