You never close a channel, so there is no signal for range to exit. He will simply try to receive, but there is nothing left of the dispatch.
You will need some way for your Add() function to see when it ends, if it is the last, so that it can close() channel, or you could just decrease the counter instead of using range in the loop, so you don't need to use close()
func main() { a := []int{1, 2, 3, 4, 5, 6, 7} n := len(a) ch := make(chan int) go Add(a[:n/2], ch) go Add(a[n/2:], ch) sum := 0
DEMO: http://play.golang.org/p/oHcrUStjmm
source share