github-vet / github-vet/rangeloop-pointer-findings
JalfResi/HostMatcherHandler: handler.go; 14 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [JalfResi/HostMatcherHandler](https://www.github.com/JalfResi/HostMatcherHandler) at [handler.go](https://github.com/JalfResi/HostMatcherHandler/blob/99683c80ae820c1be010e41d5239b5a179bdfb0e/handler.go#L61-L74)
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 match used in defer or goroutine at line 71
[Click here to see the code in its original context.](https://github.com/JalfResi/HostMatcherHandler/blob/99683c80ae820c1be010e41d5239b5a179bdfb0e/handler.go#L61-L74)
Click here to show the 14 line(s) of Go which triggered the analyzer.
```go
for _, match := range h.matches {
for key, value := range r.Header {
header := fmt.Sprintf("%s: %s", key, value[0])
t := match.pattern.ReplaceAllString(header, match.target)
// start our sub-request
wg.Add(1)
go func() {
defer wg.Done()
match.Fetch(t)
}()
}
}
```
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: 99683c80ae820c1be010e41d5239b5a179bdfb0e
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading handler.go at lines 61-74 and inspect how the match range variable is used by the goroutine and deferred work. Check the repository's available tests or run its existing test command; done means the analyzer warning is addressed without changing which match each sub-request uses.
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