草庐IT

errorList

全部标签

去 channel 无限循环

我正在尝试使用channel从一组goroutine中捕获错误,但channel进入无限循环,开始消耗CPU。funcUnzipFile(f*bytes.Buffer,locationstring)error{zipReader,err:=zip.NewReader(bytes.NewReader(f.Bytes()),int64(f.Len()))iferr!=nil{returnerr}iferr:=os.MkdirAll(location,os.ModePerm);err!=nil{returnerr}errorChannel:=make(chanerror)errorList:

去 channel 无限循环

我正在尝试使用channel从一组goroutine中捕获错误,但channel进入无限循环,开始消耗CPU。funcUnzipFile(f*bytes.Buffer,locationstring)error{zipReader,err:=zip.NewReader(bytes.NewReader(f.Bytes()),int64(f.Len()))iferr!=nil{returnerr}iferr:=os.MkdirAll(location,os.ModePerm);err!=nil{returnerr}errorChannel:=make(chanerror)errorList: