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

NewPage-Community/ncs-backend-3: app/game/cvar/service/cvar.go; 13 LoC

Open
#13,645 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 [NewPage-Community/ncs-backend-3](https://www.github.com/NewPage-Community/ncs-backend-3) at [app/game/cvar/service/cvar.go](https://github.com/NewPage-Community/ncs-backend-3/blob/ffd209914e197e335fd3aa0a86a12ffa6a8a0e83/app/game/cvar/service/cvar.go#L54-L66)

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 v used in defer or goroutine at line 58

[Click here to see the code in its original context.](https://github.com/NewPage-Community/ncs-backend-3/blob/ffd209914e197e335fd3aa0a86a12ffa6a8a0e83/app/game/cvar/service/cvar.go#L54-L66)

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

```go
for _, v := range res.Info {
if cvar.IsType(v.GameId, v.ModId, v.ServerId) {
go func() {
_, err := s.server.Rcon(ctx, &serverService.RconReq{
ServerId: v.ServerId,
Cmd: fmt.Sprintf("%s \"%s\"", cvar.Key, cvar.Value),
})
if err != nil {
log.Warn(err)
}
}()
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Read app/game/cvar/service/cvar.go around lines 54-66 and inspect how the goroutine uses the range variable v. Confirm whether each server request receives the intended iteration values, then check the surrounding service behavior and existing test coverage. Done means the reported range-loop capture concern is resolved or classified with supporting evidence.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.