```go
package main
import (
"xiyu/models"
//"os"
"runtime"
"fmt"
//"github.com/astaxie/beego/orm"
)
func getInfos1(url,proxy string,cat_id int,goods_thumb string,id int,a,b chan bool) {
a<-true
isok :=false
defer func(){
b<-isok
}()
//打印url
fmt.Println(url)
isok = true
}
func main() {
NCPU := runtime.NumCPU()
runtime.GOMAXPROCS(NCPU)
models.Init()
goods_url := new(models.GoodsUrl)
a :=make(chan bool,10)
b :=make(chan bool,1)
var goods_urls []*models.GoodsUrl
count ,_ := goods_url.Query().Filter("status",0).Count()
for i:=0;i<=int(count)/1000;i++ {
goods_url.Query().Filter("status",0).Limit(1000,i*1000).All(&goods_urls,"Cat_id","Url","Id","Img")
for _,v :=range goods_urls {
//循环取得v.url
go getInfos1(v.Url,"",v.Cat_id,v.Img,v.Id,a,b)
}
}
for x :=0;x < int(count); x++ {
<-a
<-b
}
}
```
代码报 a<-true
和go getInfos1(v.Url,"",v.Cat_id,v.Img,v.Id,a,b)的错误
以下是错误信息
goroutine 3643 [chan send]:
main.getInfos1(0x110e55c0, 0x1b, 0x69fbd0, 0x0, 0x21, 0x11088080, 0x33, 0x1a5
0x10fe4300, 0x10fe4340)
C:/GOPATH/src/xiyu/goods.go:9 +0x43
created by main.main
C:/GOPATH/src/xiyu/goods.go:32 +0x41d
goroutine 3644 [chan send]:
main.getInfos1(0x110e5660, 0x1b, 0x69fbd0, 0x0, 0x21, 0x11088280, 0x33, 0x1a5
0x10fe4300, 0x10fe4340)
C:/GOPATH/src/xiyu/goods.go:9 +0x43
created by main.main
C:/GOPATH/src/xiyu/goods.go:32 +0x41d
goroutine 3645 [chan send]:
main.getInfos1(0x110e5700, 0x1b, 0x69fbd0, 0x0, 0x21, 0x11088480, 0x33, 0x1a5
0x10fe4300, 0x10fe4340)
C:/GOPATH/src/xiyu/goods.go:9 +0x43
created by main.main
C:/GOPATH/src/xiyu/goods.go:32 +0x41d
有疑问加站长微信联系(非本文作者)