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

sunho/sdbx-discord-dj-bot: djbot/command.go; 11 LoC

Open
#16,553 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 [sunho/sdbx-discord-dj-bot](https://www.github.com/sunho/sdbx-discord-dj-bot) at [djbot/command.go](https://github.com/sunho/sdbx-discord-dj-bot/blob/b5e8dc77ea1bf2d78c62e6f17396ce2028308b25/djbot/command.go#L57-L67)

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 cmd used in defer or goroutine at line 60

[Click here to see the code in its original context.](https://github.com/sunho/sdbx-discord-dj-bot/blob/b5e8dc77ea1bf2d78c62e6f17396ce2028308b25/djbot/command.go#L57-L67)

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

```go
for _, cmd := range ch.Commands {
if cmd.isPreformable(prefix) {
go func() {
msg2 := cmd.Action(ch.dj, msg)
if msg != nil {
ch.dj.MsgC <- msg2
}
}()
return
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with djbot/command.go lines 57-67 and inspect how the range-loop variable is used inside the goroutine. Check the analyzer's reported range-loop capture and the surrounding command execution flow. Done means the selected command is used reliably by the goroutine and the reported issue is no longer present.

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
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.