Short for structure
.
struct
is a collection of members of different data type into a single variable
.
type Vertex struct { X int Y int } func main() { fmt.Println(Vertex{1, 2}) // {1 2} }
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.