type Action interface { OnHurt2(other Action) GetDamage() int } type Base struct { atk, hp int } func (this *Base) OnHurt(other *Base) { this.hp -= other.atk } func (this *Base) OnHurt2(other Action) { this.hp -= other.GetDamage() } func (this *Base) GetDamage() int { return 100 } type Child struct { Base } c1 := &Child{Base{atk: 20, hp: 100}} c2 := &Child{Base{atk: 40, hp: 60}} //這裏報錯cannot use type *Child to type *Base c1.OnHurt(c1) //要顯示指定Base,有沒有辦法不顯示指定 c1.OnHurt(&c2.Base) //用一個接口來轉型,可是這樣的話一個接口會很臃腫。 //有沒有好辦法,幫忙改造下 c1.OnHurt2(c2)