我正在查看有关 goroutines 和 channels 等模式的 goroutines 博客文章。
在bounded.go示例中,我看到了这个:
paths, errc := walkFiles(done, root)
// Start a fixed number of goroutines to read and digest files.
c := make(chan result) // HLc
var wg sync.WaitGroup
const numDigesters = 20
wg.Add(numDigesters)
for i := 0; i < numDigesters; i++ {
go func() {
digester(done, paths, c) // HLc
wg.Done()
}()
}
现在既然每个消化器都在处理同一个paths集合,为什么它不重复同一个文件两次呢?
慕姐8265434
相关分类