Go Structs Basic Declaration

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any Go Question?