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

Tiramis9/xj_game_server: game/101_longhudou/robot/logic/logic.go; 24 LoC

Open
#12,828 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 [Tiramis9/xj_game_server](https://www.github.com/Tiramis9/xj_game_server) at [game/101_longhudou/robot/logic/logic.go](https://github.com/Tiramis9/xj_game_server/blob/cbf88e6658bd9c23de3cd2fc02b9333f967bca11/game/101_longhudou/robot/logic/logic.go#L49-L72)

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

[Click here to see the code in its original context.](https://github.com/Tiramis9/xj_game_server/blob/cbf88e6658bd9c23de3cd2fc02b9333f967bca11/game/101_longhudou/robot/logic/logic.go#L49-L72)

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

```go
for k, v := range robotConfig {
// 判断批次是否使用中
_, ok := l.config[k]
if ok {
continue
}
// 获取机器人user id
userIDList := mysql.GameClient.LoadRobotUser(&v)
if userIDList == nil {
_ = log.Logger.Error("loadRobot err: Lack of robots")
return
}
// 模拟真实用户登陆
go func() {
for _, userID := range userIDList {
//随机3-10秒登录
robotUser := new(gameRobot.Robot)
robotUser.OnInit(userID, k, gate.Module.Gate, callbackCloseAgent)
gameRobot.List.Store(userID, robotUser)
robotUser.Login()
time.Sleep(time.Millisecond * 500)
}
}()
}

```

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: cbf88e6658bd9c23de3cd2fc02b9333f967bca11

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.