HomeToolsAbout a20k

Struct

What is it

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} }

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.

© VincentVanKoh