NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
``` package main import "fmt" type Usb interface { Start() Stop() } type Phone struct { } func (u Phone)Start() { fmt.Println("phone start ....") } func (u Phone)Stop() { fmt.Println("phone stop ....") } type Camora struct { } func (u Camora)Start() { fmt.Println("Camora start ....") } func (u Camora)Stop() { fmt.Println("Camora stop ....") } func TestUsb(u Usb) { u.Start() u.Stop() } func main() { var phone Usb = Phone{} phone.Start() phone.Stop() var camora Usb = Camora{} camora.Start() camora.Stop() var phone1 Phone var camora1 Camora TestUsb(phone1) TestUsb(camora1) } ```