🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` 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) } ```