Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Created February 18, 2020 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topherPedersen/ddb4756d6cdba51af3c14a44a732ea56 to your computer and use it in GitHub Desktop.
Save topherPedersen/ddb4756d6cdba51af3c14a44a732ea56 to your computer and use it in GitHub Desktop.
Structs in Golang
package main
import(
"fmt"
)
func main() {
fmt.Println("It's time to learn about Structs...")
chris := Person{FirstName: "Christopher", LastName: "Pedersen", Age: 33, Height: 68, Sex: "male"}
fmt.Println("Our first struct is a Person")
fmt.Printf("Our Person's first name is: %s \n", chris.FirstName)
fmt.Printf("Last name is: %s \n", chris.LastName)
fmt.Printf("Age: %d \n", chris.Age)
fmt.Printf("Height (in inches): %d \n", chris.Height)
fmt.Printf("Sex: %s", chris.Sex)
}
type Person struct {
FirstName string
LastName string
Age int
Height int
Sex string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment