github-vet / github-vet/rangeloop-pointer-findings
the-rileyj/uyghurs: server/main.go; 46 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [the-rileyj/uyghurs](https://www.github.com/the-rileyj/uyghurs) at [server/main.go](https://github.com/the-rileyj/uyghurs/blob/d2a849eda6f19ccd5c147bd4fb7adc644fc60e1f/server/main.go#L278-L323)
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 hongKongBuildSetting used in defer or goroutine at line 290
[Click here to see the code in its original context.](https://github.com/the-rileyj/uyghurs/blob/d2a849eda6f19ccd5c147bd4fb7adc644fc60e1f/server/main.go#L278-L323)
Click here to show the 46 line(s) of Go which triggered the analyzer.
```go
for _, hongKongBuildSetting := range messageData.ProjectMetadata.BuildsInfo {
timeoutContext, cancel := context.WithTimeout(context.Background(), time.Minute)
type pullResponse struct {
err error
}
responseChan := make(chan pullResponse)
go func() {
imagePullResponse, err := cli.ImagePull(
timeoutContext,
fmt.Sprintf("docker.io/therileyjohnson/%s_%s:latest", messageData.GithubData.Repository.Name, hongKongBuildSetting.Name),
types.ImagePullOptions{
All: true,
},
)
io.Copy(ioutil.Discard, imagePullResponse)
responseChan <- pullResponse{err}
}()
var pushErr error
select {
case <-timeoutContext.Done():
pushErr = timeoutContext.Err()
if pushErr != nil {
fmt.Println("pulling image timed out")
}
case responseInfo := <-responseChan:
pushErr = responseInfo.err
}
cancel()
if pushErr != nil {
fmt.Println("error pulling image:", pushErr)
return
}
fmt.Println("pulled image successfully")
}
```
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: d2a849eda6f19ccd5c147bd4fb7adc644fc60e1f
Contributor guide
No contributing guide indexed for this repository
Research direction
Read server/main.go lines 278-323 at commit d2a849eda6f19ccd5c147bd4fb7adc644fc60e1f, starting with the range loop and its goroutine. Check whether the reported loop-variable capture is a real bug, mitigated by the surrounding behavior, or desirable, then leave the corresponding reaction on the issue.
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
- 35/100