Contents

Go Interface

Contents
package main

import "fmt"

// 接口定义
type USB interface {
	info() string
	connect() string
}

type Infomation struct {
	name string
	model string
}
//实现
func (mobile Infomation) info() string{
	return mobile.name+mobile.model
}
// 实现
func (pc Infomation) connect() string{
	return pc.name
}

func main() {
	var u USB
	u = Infomation{name:"nokia", model:"n-73"}
	u.connect()
	fmt.Println(u)

	
}