type User struct {
Name string
Age int
}
type Location struct {
Province string
City string
}
type UserInfo struct {
U User
L Location
}
func main() {
userList := make([]UserInfo, 0)
userList = append(userList, UserInfo{
U: User{
Name: "郭强",
Age: 18,
},
L: Location{
Province: "四川",
City: "成都",
},
})
userList = append(userList, UserInfo{
U: User{
Name: "黄骞",
Age: 18,
},
L: Location{
Province: "江苏",
City: "南京",
},
})
gutil.Dump(userList)
}
// Output:
[
{
U: {
Name: "郭强",
Age: 18,
},
L: {
Province: "四川",
City: "成都",
},
},
{
U: {
Name: "黄骞",
Age: 18,
},
L: {
Province: "江苏",
City: "南京",
},
},
]