You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
449 B

3 years ago
package main
import "fmt"
// Person2 匿名结构体
type Person2 struct {
string
int
}
// Address 嵌套结构体
type Address struct {
Province, City string
}
type User struct {
Name string
Age int
Address
}
func main() {
p1 := Person2{
"132",
18,
}
fmt.Printf("p1: %#v\n", p1)
user := User{
Name: "song",
Age: 18,
Address: Address{
Province: "anhui",
City: "An qing",
},
}
fmt.Printf("%#v\n", user.City)
}