github-vet / github-vet/rangeloop-pointer-findings

13105005020/DPServer: autoSign.go; 42 LoC

Open
#18,039 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [13105005020/DPServer](https://www.github.com/13105005020/DPServer) at [autoSign.go](https://github.com/13105005020/DPServer/blob/683a4af8e8e1e67b83fef5c7e0dc5e6e99c3ddf2/autoSign.go#L45-L86)

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 cookie used in defer or goroutine at line 66

[Click here to see the code in its original context.](https://github.com/13105005020/DPServer/blob/683a4af8e8e1e67b83fef5c7e0dc5e6e99c3ddf2/autoSign.go#L45-L86)

Click here to show the 42 line(s) of Go which triggered the analyzer.

```go
for phone, cookie := range phoneArr {
if util.InArrayInt(history[phone], id) {
continue
}
signUrl := "https://m.dianping.com/mobile/dinendish/apply/doApplyActivity"
postData := map[string]interface{}{
"env": 1,
"offlineActivityId": id,
"phoneNo": phone,
}
header := map[string]string{
"Accept": " application/json, text/plain, */*",
"Content-Type": " application/json;charset=UTF-8",
"Origin": " https://m.dianping.com",
"Referer": " https://m.dianping.com/mobile/dinendish/apply/1331624928?a=1&source=null&utm_source=null&showShopId=0&token=%2a&uiwebview=1",
"User-Agent": " Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
}
util.Putln(phone)
go func() {
flag:=0
for i := 0; i < 5; i++ {
resp := util.RequestPost(signUrl, cookie, postData, map[string]string{}, header)
var respMap map[string]interface{}
json.Unmarshal([]byte(resp), &respMap)
util.Putln(string(resp))
switch int(respMap["data"].(map[string]interface{})["code"].(float64)) {
case 404:
flag=1
util.PushWeChat(phone+"登录过期", "")
case 400:
util.Putln("报名失败")
case 200:
flag=1
util.Putln("报名成功")
}
if flag==1{
break
}
history[phone] = append(history[phone], id)
}
}()
}

```

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: 683a4af8e8e1e67b83fef5c7e0dc5e6e99c3ddf2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.