github-vet / github-vet/rangeloop-pointer-findings
CharlesWong/VisualOctopus: scraper.go; 34 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [CharlesWong/VisualOctopus](https://www.github.com/CharlesWong/VisualOctopus) at [scraper.go](https://github.com/CharlesWong/VisualOctopus/blob/bf230856eb5c070e0251035e732aafb528880d55/scraper.go#L400-L433)
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 task used in defer or goroutine at line 402
[Click here to see the code in its original context.](https://github.com/CharlesWong/VisualOctopus/blob/bf230856eb5c070e0251035e732aafb528880d55/scraper.go#L400-L433)
Click here to show the 34 line(s) of Go which triggered the analyzer.
```go
for _, task := range tasks {
go func() {
for id := task.GetIdProfileTask().BeginId - 1; id < task.GetIdProfileTask().EndId && !util.IsLowDiskSpace(); id++ {
chTask <- 1
taskId := int(id)
go func() {
defer func() {
<-chTask
}()
log.Println("Crawling Id: ", taskId)
url := fmt.Sprintf(ProfileTemplate[task.GetType()], taskId)
profile, err := crawl(int(taskId), url, task.GetType())
if err != nil {
log.Println(err)
return
}
if profile != nil && len(profile.ImageURLs) >= int(c.ValidImgNum) {
save(profile, task.GetType())
}
}()
if int(taskId+1)%archive.ArchiveSize == 0 {
err := archive.Archive(taskId+1-archive.ArchiveSize, taskId+1, c.ArchiveFolder, SiteName[task.GetType()], path.Join(c.DataFolder, SiteName[task.GetType()]))
if err != nil {
log.Println(err)
}
}
task.GetIdProfileTask().BeginId = int64(taskId)
err := config.SaveTasks()
if err != nil {
log.Println(err)
}
}
}()
}
```
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: bf230856eb5c070e0251035e732aafb528880d55
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.