Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
package main import ("fmt") type Person struct { name string age int job string salary int } func main() { var pers1 Person var pers2 Person // Pers1 specification pers1.name = "Hege" pers1.age = 45 pers1.job = "Teacher" pers1.salary = 6000 // Pers2 specification pers2.name = "Cecilie" pers2.age = 24 pers2.job = "Marketing" pers2.salary = 4500 // Access and print Pers1 info fmt.Println("Name: ", pers1.name) fmt.Println("Age: ", pers1.age) fmt.Println("Job: ", pers1.job) fmt.Println("Salary: ", pers1.salary) // Access and print Pers2 info fmt.Println("Name: ", pers2.name) fmt.Println("Age: ", pers2.age) fmt.Println("Job: ", pers2.job) fmt.Println("Salary: ", pers2.salary) }
Name: Hege Age: 45 Job: Teacher Salary: 6000 Name: Cecilie Age: 24 Job: Marketing Salary: 4500