Composite values and structs in Go
A data type made up of several values that you can treat as a single unit is called a composite type.
A struct
in Go groups together related pieces of data, called fields.
E.g.:
1// Customer represents information about a customer.
2type Customer struct {
3 Name string
4 Email string
5}
Comments before a struct definition get turned into browsable documentation when published to github.
The type
keyword introduces a new type definition. The struct
keyword specifies which kind of new type we are creating.
Everything after type Customer ...
is a type literal.
References
- John Arundel, For the Love of Go
Next -> exported-identifiers-in-go
Next -> writing-struct-literals-in-go
#programming #type #golang #composite #struct #github #for_the_love_of_go #documentation