1

go 接口(interface)?

 2 years ago
source link: https://studygolang.com/articles/35411
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

go 接口(interface)?

ysxdashing · 大约4小时之前 · 75 次点击 · 预计阅读时间不到 1 分钟 · 大约8小时之前 开始浏览    




有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:701969077

9 回复  |  直到 2022-01-20 15:36:14

whoam1 · #1 · 大约4小时之前

我的理解:接口是为了抽象和解耦合。 让使用者依赖接口而不是依赖实现

liangmanlin · #2 · 大约4小时之前

对,没有用,不要学go,也不要学编程

GO_go_GO1 · #3 · 大约6小时之前

理解理解再说

ysxdashing · #4 · 大约8小时之前

你这人有病 说话阴阳怪气的,神经病,你要是不想回答就别回答。人品有问题

ysxdashing · #5 · 大约8小时之前

就是因为不理解为什么这样写,才问的哈

ysxdashing · #6 · 大约8小时之前

抽象应该是把相同类似的功能写一遍,而不是所有的需要这个方法的结构体都要实现

whoam1 · #7 · 大约8小时之前

接口是一种类型、go的接口相当于其他语言的父类

ysxdashing · #8 · 大约8小时之前

子类应该是有父类的属性和方法的,相同的方法和属性应该写在父类中,子类继承就好。谢谢回复

ysxdashing · #9 · 大约8小时之前

go的接口中的方法 是需要每个结构体自己实现,这样不就冗余了吗,也可能是我刚学go,还不知道接口的妙用。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK