Skip to content

Instantly share code, notes, and snippets.

@alfianmalik
Created May 24, 2020 16:31
Show Gist options
  • Save alfianmalik/30410b21aaf3c0e525cc23ba102a0465 to your computer and use it in GitHub Desktop.
Save alfianmalik/30410b21aaf3c0e525cc23ba102a0465 to your computer and use it in GitHub Desktop.
package people
// Declares a variable of type 'Person'. The internal fields of the p variable
// are set to their zero value i.e. FirstName is an empty string and Age is 0
var p Person
// Instantiate a struct by supplying the value of all the struct fields.
var p = Person{"Joe", "Sweeny", 36}
// Initialize a struct by supplying name: value pairs of all the struct fields.
var p = Person{FirstName: "Joe", LastName: "Sweeny", Age: 36}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment