本人初学go,遇到了goj里结构包含,然后调用函数的问题
type User struct {
Id int
Name string
}
type School struct {
User
class int
}
u := User{Name: "song", Id: 1}
u.sb(2)
s := School{User: User{Name: "li", Id: 2}, class: 3}
s.sb(4)
func (p User) sb(o int) {
fmt.Println(o, p.Id, p.Name, p.class)
}
能不能在不写func (p School) sb(o int) 这样一个函数的情况下 ,在同一个函数里调用Id,Name,class 这三个参数