Golang 面向对象
继承 package main import ( "fmt" ) type People struct { name string age int weight int } type Student struct { People specialty string } // define sayHi method on People struct func (p People) sayHi() { fmt.Println(1) } func main() { p := People{"syy", 1, 2} s := Student{People{"syy", 1, 2}, "Seecialty"} p.sayHi() s.sayHi() } 下面的方法,主要作用是在People结构体上定义...阅读全文