假如我有一个HUAWEI类,要实现Phone接口,能够这样做:
package mainimport "fmt"//定义一个接口type Phone interface { call()}//定义一个类type HUAWEI struct { name string}//用下面的HUAWEI类实现下面的Phone接口func (myPhone HUAWEI) call() { fmt.Println("this is the coolest phone all around the world")}func main() { thisPhone := new(HUAWEI) thisPhone.call()}