继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

go语言接口做参数示例

幕布斯7119047
关注TA
已关注
手记 432
粉丝 28
获赞 99

    今天给大家说一说go语言接口做参数示例,话不多说直接上代码:

type IUserService interface {

GenId()

}

type UserService struct {

id string

}

func (u *UserService) GenId() {

generateUUID, _ := uuid.GenerateUUID()

u.id = generateUUID

}

func BuildUser(service IUserService) {

service.GenId()

}

func main() {

userService := UserService{}

BuildUser(&userService)

//BuildUser(userService) *UserService实现了IUserService,UserService没有实现IUserService 

println(userService.id)

}

    以上便是go语言接口做参数示例的全部内容,更多内容可关注慕课网其他文章~

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP