github-vet / github-vet/rangeloop-pointer-findings
Igosuki/golang_workshop_concurrency: rss.go; 55 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Igosuki/golang_workshop_concurrency](https://www.github.com/Igosuki/golang_workshop_concurrency) at [rss.go](https://github.com/Igosuki/golang_workshop_concurrency/blob/728cbb2f7dbcb42344456f3dbc6e449e9de24c67/rss.go#L99-L153)
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 f used in defer or goroutine at line 129
[Click here to see the code in its original context.](https://github.com/Igosuki/golang_workshop_concurrency/blob/728cbb2f7dbcb42344456f3dbc6e449e9de24c67/rss.go#L99-L153)
Click here to show the 55 line(s) of Go which triggered the analyzer.
```go
for _, f := range cs.fetchers {
var next time.Time
var pending []Item
var err error
var fetchDone chan fetchResult
guids := make(map[string]bool)
go func() {
for {
var feed chan Item
var first Item
if len(pending) > 0 {
first = pending[0]
feed = cs.feed
}
var delay time.Duration
if now := time.Now(); next.After(now) {
delay = next.Sub(time.Now())
}
var startFetch <-chan time.Time
if fetchDone == nil && len(pending) < cs.maxPending {
startFetch = time.After(delay)
}
select {
case closingChan := <-cs.closing:
closingChan <- cs.errors
return
case <-startFetch:
var items []Item
fetchDone = make(chan fetchResult, 1)
go func() {
items, next, err = f.Fetch()
fetchDone <- fetchResult{items, next, err}
}()
case result := <-fetchDone:
fetchDone = nil
if result.err != nil {
log.Errorln(err)
cs.errors = append(cs.errors, err)
next = time.Now().Add(10 * time.Second)
break
}
next = result.next
for _, item := range result.fetched {
if !guids[item.GUID] {
pending = append(pending, item)
guids[item.GUID] = true
}
}
case feed <- first:
pending = pending[1:]
}
}
}()
}
```
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: 728cbb2f7dbcb42344456f3dbc6e449e9de24c67
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.