1.go里面接口必须使用interface 这个案例也体现了多台特性
package main import "fmt" type Usb interface { work() finish() } type Phone struct { } func ( phone Phone) work(){ fmt.Println("phone is working"); } func (phone Phone) finish(){ fmt.Println("phone is finish"); } type Camera struct { } func(ca Camera) work(){ fmt.Println("camera is workding"); } func (ca Camera) finish(){ fmt.Println("camera is finish"); } type Computer struct { } func (com Computer) start(usb Usb){ usb.work(); usb.finish(); } func main(){ com:=Computer{}; phone:=Phone{}; com.start(phone); }