
The Go Workshop
By :

Collections are perfect for grouping values of the same type and purpose together. There is another way of grouping data together in Go for a different purpose. Often, a simple string, number, or Boolean doesn't fully capture the essence of the data you'll have.
For example, for our user map, a user was represented by their unique ID and their first name. That is rarely going to be enough details to be able to work with user records. The data you could capture about a person is almost infinite, such as their given, middle, and family names. Their preferred prefix and suffix, their date of birth, their height, weight, or where they work can also be captured. It would be possible to store this data in multiple maps, all with the same key, but that is hard to work with and maintain.
The ideal thing to do is collect all these different bits of data into a single data structure that you can design and control. That's what Go's struct type is: it&apos...