yo.go
· 424 B · Go
Raw
package main
import "fmt"
type Person struct {
Name string
Age int
Country string
}
func main() {
// Create a new instance of the Person struct
p := Person{
Name: "John",
Age: 30,
Country: "USA",
}
// Access and print the fields of the Person struct
fmt.Println("Name:", p.Name)
fmt.Println("Age:", p.Age)
fmt.Println("Country:", p.Country)
}
1 | package main |
2 | |
3 | import "fmt" |
4 | |
5 | type Person struct { |
6 | Name string |
7 | Age int |
8 | Country string |
9 | } |
10 | |
11 | func main() { |
12 | // Create a new instance of the Person struct |
13 | p := Person{ |
14 | Name: "John", |
15 | Age: 30, |
16 | Country: "USA", |
17 | } |
18 | |
19 | // Access and print the fields of the Person struct |
20 | fmt.Println("Name:", p.Name) |
21 | fmt.Println("Age:", p.Age) |
22 | fmt.Println("Country:", p.Country) |
23 | } |