October 2015
Beginner to intermediate
400 pages
14h 44m
English
One of the most interesting and novel aspects of Go is its support for concurrent programming. This is a large topic, to which Chapter 8 and Chapter 9 are devoted, so for now we’ll give you just a taste of Go’s main concurrency mechanisms, goroutines and channels.
The next program, fetchall, does the same fetch of a URL’s contents as
the previous example, but it fetches many URLs, all
concurrently, so that the process will take no longer than the longest
fetch rather than the sum of all the fetch times. This version of
fetchall discards the
responses but reports the size and elapsed time for each one:
// Fetchall fetches URLs in parallel and reports their times ...