github-vet / github-vet/rangeloop-pointer-findings
hahwul/mzap: pkg/zap/zap.go; 31 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [hahwul/mzap](https://www.github.com/hahwul/mzap) at [pkg/zap/zap.go](https://github.com/hahwul/mzap/blob/2496e90dc63313b453890025dd419096eccfe42e/pkg/zap/zap.go#L58-L88)
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 api used in defer or goroutine at line 62
[Click here to see the code in its original context.](https://github.com/hahwul/mzap/blob/2496e90dc63313b453890025dd419096eccfe42e/pkg/zap/zap.go#L58-L88)
Click here to show the 31 line(s) of Go which triggered the analyzer.
```go
for _, api := range arrayAPIs {
wg.Add(1)
go func() {
for target := range urlChan {
req, err := http.NewRequest("GET", api+prefix, nil)
if err != nil {
panic(err)
}
q := req.URL.Query()
q.Add("url", target)
req.URL.RawQuery = q.Encode()
if options.APIKey != "" {
req.Header.Add("X-ZAP-API-Key", options.APIKey)
}
client := &http.Client{}
resp, err := client.Do(req)
log.WithFields(log.Fields{
"Target": target,
"ZAP API": api,
}).Info("Added")
if err != nil {
//panic(err)
}
defer resp.Body.Close()
}
wg.Done()
}()
}
```
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: 2496e90dc63313b453890025dd419096eccfe42e
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.