github-vet / github-vet/rangeloop-pointer-findings
acaloiaro/di-tui: main.go; 8 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [acaloiaro/di-tui](https://www.github.com/acaloiaro/di-tui) at [main.go](https://github.com/acaloiaro/di-tui/blob/cf2887fc1d7f2c15e6e46d1f63469d8dd57e9c04/main.go#L178-L185)
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.
> function call which takes a reference to chn at line 182 may start a goroutine
[Click here to see the code in its original context.](https://github.com/acaloiaro/di-tui/blob/cf2887fc1d7f2c15e6e46d1f63469d8dd57e9c04/main.go#L178-L185)
Click here to show the 8 line(s) of Go which triggered the analyzer.
```go
for _, chn := range channels {
// favorites are prefixed with "DI.fm - ", shave it off before comparing
// TODO: this feels a bit hacky -- consider doing something else.
if chn.Name == f.Name[8:len(f.Name)] {
app.PlayChannel(&chn, ctx)
return
}
}
```
Click here to show extra information the analyzer produced.
```
The following graphviz dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(PlayChannel, 2)" -> {"(Stream, 2)";"(UpdateNowPlaying, 2)";}
"(Stream, 2)" -> {}
"(UpdateNowPlaying, 2)" -> {}
}
```
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: cf2887fc1d7f2c15e6e46d1f63469d8dd57e9c04
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with main.go lines 178-185 and inspect the PlayChannel call and the related call graph shown in the issue. Determine whether passing the range-loop variable reference can cause incorrect behavior, then classify the finding as Bug, Mitigated, or Desirable Behavior using the linked project guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100