github-vet / github-vet/rangeloop-pointer-findings
Collapsars/w3s.com.cn_go: src/w3s.com.cn/main/app_hander_try_02.go; 146 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Collapsars/w3s.com.cn_go](https://www.github.com/Collapsars/w3s.com.cn_go) at [src/w3s.com.cn/main/app_hander_try_02.go](https://github.com/Collapsars/w3s.com.cn_go/blob/a0482b8a289a22343045ab6a6c64cef88e7b1ad0/src/w3s.com.cn/main/app_hander_try_02.go#L44-L189)
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.
> function call which takes a reference to value at line 133 may start a goroutine
[Click here to see the code in its original context.](https://github.com/Collapsars/w3s.com.cn_go/blob/a0482b8a289a22343045ab6a6c64cef88e7b1ad0/src/w3s.com.cn/main/app_hander_try_02.go#L44-L189)
Click here to show the 146 line(s) of Go which triggered the analyzer.
```go
for _,value := range articles {
//fmt.Println(value.Type)
doc , err := goquery.NewDocumentFromReader(strings.NewReader(value.Content))
utils.CheckErr(err)
//移除上面广告
doc.Find(".ad").Each(func(i int , s *goquery.Selection) {
//fmt.Println(s.Html())
s.Remove()
})
//移除上面广告
doc.Find("label.pull-right").Each(func(i int , s *goquery.Selection) {
//fmt.Println(s.Html())
s.Remove()
})
//移除div display:none;
doc.Find("div").Each(func(i int , s *goquery.Selection) {
stylet , _ :=s.Attr("style")
//fmt.Println(stylet)
if(stylet == "display:none;"){
s.Remove()
}
//fmt.Println(s.Html())
//
//s.Remove()
})
r, _ := regexp.Compile("runcode")
//fmt.Println(scriptText)
//http://tool.runoob.com/compile.php
scriptText, _:= doc.Html()
if (r.MatchString(scriptText)){
//fmt.Println(scriptText)
rr, _ := regexp.Compile("http://tool.runoob.com/compile.php")
value.Content = string(rr.ReplaceAll([]byte(scriptText),[]byte("/html/run")))
}else {
value.Content = scriptText
}
////去掉
//doc.Find("a").Each(func(i int , s *goquery.Selection) {
// link,_ := s.Attr("href")
// r, _ := regexp.Compile("^http://www.runoob.com/")
// if r.MatchString(link){
// //fmt.Println(link)
// path := string(r.ReplaceAll([]byte(link),[]byte("/")))
// s.SetAttr("href",path)
// //fmt.Println(path)
// }
//})
//article := Article{};
//article.Id = value.Id
//value.Content = scriptText
//Content,err := doc.Html()
//fmt.Println(value.Content)
//fmt.Println(value.Id)
fmt.Println(time.Now().UnixNano())
//fmt.Println(value.Content)
//fmt.Println(value.Content)
db.Save(&value)
count ++
/*
ch <- 1
go func() {
doc , err := goquery.NewDocumentFromReader(strings.NewReader(value.Content))
utils.CheckErr(err)
//移除右边
doc.Find(".right-column").Each(func(i int , s *goquery.Selection) {
//fmt.Println(s.Html())
s.Remove()
})
/*
//移除广告
doc.Find("ins").Each(func(i int , s *goquery.Selection) {
s.Remove()
})
//移除google script广告
doc.Find("script").Each(func(i int , s *goquery.Selection) {
s.Remove()
})
//移除google script广告
doc.Find("script").Each(func(i int , s *goquery.Selection) {
s.Remove()
})
//移除试一试菜鸟工具
doc.Find("#RightPane .pull-right a").Each(func(i int , s *goquery.Selection) {
s.Remove()
})
//article := Article{};
//article.Id = value.Id
value.Content,err = doc.Html()
//Content,err := doc.Html()
//fmt.Println(value.Content)
fmt.Println(value.Id)
fmt.Println(time.Now().UnixNano())
db.Save(&value)
//count ++
<- ch
}()
*/
//fmt.Println(doc.Html())
}
```
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: a0482b8a289a22343045ab6a6c64cef88e7b1ad0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.