type Person struct {
// 属性
name string
age int
sex bool
hobby []string
}
// 方法
func (p Person)Eat() {
fmt.Println("eat...")
}
func (p *Person)Eat() {
fmt.Println("eat...")
}
func main() {
james := Person{}
james.Eat()
}
我知道(p *Person) 是在使用方法时候传入的是指针,(p Person)使用方法时候传入的是对象。
也就是说,james.Eat() 这个时候,james基于方法上面p的类型,使用方法时候传递对象或者指针吗?