Struct
What is it
Short for structure.
struct is a collection of members of different data type into a single variable.
- typed collections of fields. They’re useful for grouping data together to form records.
type Vertex struct { X int Y int } func main() { fmt.Println(Vertex{1, 2}) // {1 2} }
Alignment Convention
Align to the longest property in struct
type Options struct { shortAttr string longerAttribute string attr int }
struct vs Array
Arrays are used to store multiple values of same data type into a single variable.
Structs are used to store multiple values of different data types into a single variable.