September 2017
Intermediate to advanced
466 pages
9h 33m
English
In this section, we will talk about creating and using a channel of channels. Two possible reasons to use such a channel are as follows:
The name of the naive program that will be developed in this section is cOfC.go and will be presented in four parts.
The first part of the program is the following:
package main
import (
"fmt"
)
var numbers = []int{0, -1, 2, 3, -4, 5, 6, -7, 8, 9, 10}
The second part of the program is the following:
func f1(cc chan chan int, finished chan struct{}) { c := make(chan int) cc <- c defer close(c) total := 0 i := 0 for { select { case c <- numbers[i]: ...Read now
Unlock full access