Basic Declaration

Download go eBook

Example

A basic struct is declared as follows:

type User struct {
    FirstName, LastName string
    Email               string
    Age                 int
}

Each value is called a field. Fields are usually written one per line, with the field's name preceeding its type. Consecutive fields of the same type may be combined, as FirstName and LastName in the above example.

Stats

Contributors: 3
2016-10-08
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook