New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: Go 2: add a keyword to facilitate the implementation of the interface mechanism #35645
Comments
If I understand your example, it would work if you simply omitted the words |
First of all, my colleague and I sometimes complain that it is difficult to find which interface the structure is implemented in go. Moreover, a few days ago, when I needed to implement three interfaces in a reusable logic, I needed to jump to the location defined by the interface to copy the function signature every time. I think this is very inconvenient. If each interface needs to implement 10 functions, then I will crash directly. It was a very good idea, but it was very painful to implement. I have to do a lot of copying and jumping operations. and so
首先,我和我的同事有时抱怨在 go 里面找那个结构体实现了哪个接口很困难。 <哪位老哥英语好的再帮我解释下> |
Looks like you need buy a good ide (like GoLand): it can generate all code in an interface for you. |
我一直在使用这个IDE,但是没找到快速生成实现接口代码的方法。能指导一下吗 |
请在 https://www.jetbrains.com/go/features/ 页面搜索 'interface' . |
谢谢指导,我指导该怎么做了 |
This is the trouble I encountered at work.
在 go 中实现一个接口,需要自己找到并实现
interface
下面所有的函数,在代码量非常多的项目中,这么做非常不方便,为什么不像其他语言那样,用一个impl
关键字将实现一个接口的所有函数聚合到一处 。就像下面的例子:To implement an interface in go, you need to find and implement all the functions of the interface. In a project with a lot of code, this is very inconvenient. Why not use an impl keyword to generate all the functions of an interface together.Like the example below:
这样,IDE 就可以为我们省下不少的工作
In this way, the IDE can save a lot of work for us.
The text was updated successfully, but these errors were encountered: