企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
``` 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) } ```