Created
February 18, 2020 10:47
-
-
Save topherPedersen/ddb4756d6cdba51af3c14a44a732ea56 to your computer and use it in GitHub Desktop.
Structs in Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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