If you've been working with functional or dynamic programming languages, you may feel that for loops and if statements produce verbose code. Using functional constructs such as map and filter for processing lists can be useful and make code appear more readable; however, in Go, these types are not in the standard library, and can be difficult to generalize without generics or very complex reflection and the use of empty interfaces. This recipe will provide you with some basic examples of implementing collections using Go closures.
How to do it...
The following steps cover how to write and run your application:
- From your Terminal/console application,createa new directory called~/projects/go-programming-cookbook/chapter3/collections.
- Navigate to this directory.
- Run the following command:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second...