The example relies on the fact that jobs and results channel buffers are big enough. If the code is changed to use smaller buffers for these channels:
jobs
results
jobs := make(chan int, 2) results := make(chan int, 2)
then example program will deadlock: http://play.golang.org/p/whGg0n8qgT
Also in practice number of jobs is variable and it is hard to find the right size for the channels buffer that will work in all cases. This should at least be explained on the example page.
The example relies on the fact that
jobsandresultschannel buffers are big enough. If the code is changed to use smaller buffers for these channels:then example program will deadlock: http://play.golang.org/p/whGg0n8qgT
Also in practice number of jobs is variable and it is hard to find the right size for the channels buffer that will work in all cases. This should at least be explained on the example page.