August 2019
Beginner to intermediate
798 pages
17h 2m
English
Although arrays, slices, and maps are all very useful, they cannot group and hold multiple values in the same place. When you need to group various types of variables and create a new handy type, you can use a structure. The various elements of a structure are called the fields of the structure or just fields.
I will start this section by explaining a simple structure that was first defined in the sortSlice.go source file of the previous chapter:
type aStructure struct {
person string
height int
weight int
}
For reasons that will become evident in Chapter 6, What You Might Not Know About Go Packages and Go Functions, the fields of a structure usually begin with an uppercase letter – this mainly depends on what you want to do with ...
Read now
Unlock full access