In this worker pool, what bug causes a deadlock or panic, and what is the standard fix?
func run(jobs []int) []int {
in := make(chan int)
out := make(chan int)
for w := 0; w < 4; w++ {
go func() {
for j := range in {
out <- j * j
}
}()
}
for _, j := range jobs {
in <- j
}
close(in)
var res []int
for r := range out {
res = append(res, r)
}
return res
}