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

mholt/photobak: repo.go; 20 LoC

Open
#11,493 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 [mholt/photobak](https://www.github.com/mholt/photobak) at [repo.go](https://github.com/mholt/photobak/blob/d5eeac91fd4a1d9da652939eceab25438a603f3a/repo.go#L245-L264)

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 ac used in defer or goroutine at line 254

[Click here to see the code in its original context.](https://github.com/mholt/photobak/blob/d5eeac91fd4a1d9da652939eceab25438a603f3a/repo.go#L245-L264)

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

```go
for _, ac := range accounts {
listedCollections, err := ac.client.ListCollections()
if err != nil {
return err
}
for _, listedColl := range listedCollections {
throttle <- struct{}{}
go func(listedColl Collection) {
defer func() { <-throttle }()
err := r.processCollection(listedColl, ac, ctxChan, saveEverything, checkIntegrity, &collWg)
if err != nil {
log.Printf("[ERROR] processing %s: %v", listedColl.CollectionName(), err)
return
}
}(listedColl)
}
for i := 0; i < cap(throttle); i++ {
throttle <- struct{}{} // make sure all goroutines finish
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Read repo.go lines 245-264 at commit d5eeac91fd4a1d9da652939eceab25438a603f3a and inspect the linked photobak context, focusing on the goroutine's use of ac. Decide whether the analyzer finding is a Bug, Mitigated, or Desirable Behavior, then leave the corresponding reaction; done means the finding has been classified.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.