Go channels, in combination with Goroutines, are first-class citizens for asynchronous communication. Channels become especially powerful when we use select statements. These statements allow a Goroutine to intelligently handle requests from multiple channels at once.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter10/channelsand navigate to it.
- Run the following command:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter10/channels
You should see a file calledgo.modthat contains the following code:
module github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter10/channels
- Copy the tests from~/projects/go-programming-cookbook-original/chapter10...