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

bkumar0801/number-service: appcontext/responsebuilder.go; 14 LoC

Open
#15,784 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 [bkumar0801/number-service](https://www.github.com/bkumar0801/number-service) at [appcontext/responsebuilder.go](https://github.com/bkumar0801/number-service/blob/b95b0b3cd21a0817fa841aa9328fbefb06c3b389/appcontext/responsebuilder.go#L39-L52)

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 requesturl used in defer or goroutine at line 41

[Click here to see the code in its original context.](https://github.com/bkumar0801/number-service/blob/b95b0b3cd21a0817fa841aa9328fbefb06c3b389/appcontext/responsebuilder.go#L39-L52)

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

```go
for _, requesturl := range urls {
// Invokes a go routine for each request url
go func() { c <- appCtx.Get(requesturl) }()
// Response is ignored after timeout (500ms)
timeout := time.After(constant.Timeout * time.Millisecond)
select {
case result := <-c:
for _, v := range result.Numbers {
set[v] = true
}
case <-timeout:
return nil
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Review appcontext/responsebuilder.go lines 39-52, starting with the range over urls and its goroutine closure. Determine whether requesturl is incorrectly captured and classify the finding as Bug, Mitigated, or Desirable Behavior by leaving the corresponding reaction.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.