The importance of concurrency
So far, we’ve seen how to use concurrency to split work over several Goroutines, but in all of these exercises, concurrency was not really needed. In fact, you do not save much time doing what we did, nor do you have any other advantage. Concurrency is important when you need to perform several tasks that are logically independent of each other, and the easiest case to understand is a web server. You saw in Chapter 16, Web Servers, that several clients will most likely connect to the same server and all these connections will result in the server performing some actions. Also, these actions are all independent; that’s where concurrency is important, as you do not want one of your users to have to wait for all other HTTP requests to be completed before their request gets handled. Another case for concurrency is when you have different data sources to gather data and you can gather that data in different Goroutines and combine the result at...