github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2012/waza/load1 (about)

     1  type Work struct {
     2      x, y, z int
     3  }
     4  
     5  func worker(in <-chan *Work, out chan<- *Work) {
     6     for w := range in {
     7        w.z = w.x * w.y
     8        Sleep(w.z)
     9        out <- w
    10     }
    11  }
    12  
    13  func Run() {
    14     in, out := make(chan *Work), make(chan *Work)
    15     for i := 0; i < NumWorkers; i++ {
    16         go worker(in, out)
    17     }
    18     go sendLotsOfWork(in)
    19     receiveLotsOfResults(out)
    20  }