github-vet / github-vet/rangeloop-pointer-findings
ChrisGuoGQ/fei: controllers/base.go; 27 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [ChrisGuoGQ/fei](https://www.github.com/ChrisGuoGQ/fei) at [controllers/base.go](https://github.com/ChrisGuoGQ/fei/blob/ff641dd76c37af35b2f9fcb48486ba204e64e55d/controllers/base.go#L35-L61)
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 f used in defer or goroutine at line 38
[Click here to see the code in its original context.](https://github.com/ChrisGuoGQ/fei/blob/ff641dd76c37af35b2f9fcb48486ba204e64e55d/controllers/base.go#L35-L61)
Click here to show the 27 line(s) of Go which triggered the analyzer.
```go
for _, f := range files {
requests <- f.Name()
go func() {
tag := f.Name()
file, _ := os.Open(path.Join("pics", f.Name()))
params := map[string]io.Reader{
"image": file,
}
r, _ := utils.MultipartReq(cfg.Face.Minions+"/extract_with_detect", params)
body, _ := ioutil.ReadAll(r.Body)
// log.Printf("extractBody: %s", body)
featResult, _ := jsonparser.GetString(body, "faces", "[0]", "Feature")
base := models.Base{Name: tag, Tag: tag, GroupName: group, Feature: featResult}
models.CreateBase(&base)
addParams := map[string]io.Reader{
"groupname": strings.NewReader(group),
"featureid": strings.NewReader(strconv.Itoa(int(base.ID))),
"tag": strings.NewReader(tag),
"feature": strings.NewReader(featResult),
}
addResult, _ := utils.MultipartReq(cfg.Face.Group+"/group/add", addParams)
addBody, _ := ioutil.ReadAll(addResult.Body)
log.Printf("addBody: %s", addBody)
done := <-requests
log.Info(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: ff641dd76c37af35b2f9fcb48486ba204e64e55d
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.