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

blckur/blckur: accounts/hackernews.go; 26 LoC

Open
#15,678 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 [blckur/blckur](https://www.github.com/blckur/blckur) at [accounts/hackernews.go](https://github.com/blckur/blckur/blob/9403c6aa41836221f0b087d7a4101e7d1f498eba/accounts/hackernews.go#L279-L304)

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 msg used in defer or goroutine at line 287

[Click here to see the code in its original context.](https://github.com/blckur/blckur/blob/9403c6aa41836221f0b087d7a4101e7d1f498eba/accounts/hackernews.go#L279-L304)

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

```go
for msg := range sub {
if msg == nil {
return
}

go func() {
story := &hackerNewsStory{}

err := json.Unmarshal([]byte(msg.Data.(string)), story)
if err != nil {
err = &ParseError{
errors.Wrap(err, "Hacker News sub error"),
}
logrus.WithFields(logrus.Fields{
"error": err,
}).Error("accounts.hackernews: Unknown error")
}

err = b.parse(story)
if err != nil {
logrus.WithFields(logrus.Fields{
"error": err,
}).Error("accounts.hackernews: Unknown parse error")
}
}()
}

```

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: 9403c6aa41836221f0b087d7a4101e7d1f498eba

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in accounts/hackernews.go around lines 279-304 at commit 9403c6aa41836221f0b087d7a4101e7d1f498eba, and inspect how the range variable is used by the goroutine. Compare the analyzer warning with the surrounding behavior, then classify the finding as Bug, Mitigated, or Desirable Behavior using the reaction options.

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.