MCPcopy Create free account
hub / github.com/Go-Learning-Land/Go-Learning-Archive / worker

Function worker

GolangBasics/GoByExample/035WorkerPool.go:8–15  ·  view source on GitHub ↗
(id int, jobs <-chan int, results chan<- int)

Source from the content-addressed store, hash-verified

6)
7
8func worker(id int, jobs <-chan int, results chan<- int) {
9 for j := range jobs {
10 fmt.Println("worker", id, "started job", j)
11 time.Sleep(time.Second)
12 fmt.Println("worker", id, "finished job", j)
13 results <- j * 2
14 }
15}
16
17func main() {
18

Callers 1

mainFunction · 0.70

Calls 1

PrintlnMethod · 0.80

Tested by

no test coverage detected