June 2017
Beginner
1091 pages
22h 9m
English
Up to this point, the discussions about goroutines and channels remained deliberately separated to ensure that each topic is properly covered. However, the true power of channels and goroutines are realized when they are combined to create concurrent programs, as covered in this section.
One of the primary uses of channels is synchronization between running goroutines. To illustrate this use case, let us examine the following code, which implements a word histogram. The program reads the words from the data slice then, on a separate goroutine, collects the occurrence of each word:
func main() { data := []string{ "The yellow fish swims slowly in the water", "The brown dog barks loudly after a drink ...", ...Read now
Unlock full access