Goland能自动生成其他包的接口方法实现吗?
今天要学着做web框架的时候,写自己的contex时引入了context.Context接口,找了半天没找到自动生成Context接口的方法,Goland有没有什么自动生成机制或者插件可以自动生成其他包接口的方法啊
type Context struct {
request *http.Request
response http.ResponseWriter
context.Context
//超时设置
hasTimeOut bool
//写保护
writerMux *sync.RWMutex
}
// #endregion
//只能手动写完
func (ctx *Context) BaseContext() context.Context {
return ctx.request.Context()
}
// #region implement context.Context
func (ctx *Context) Deadline() (deadline time.Time, ok bool) {
return ctx.BaseContext().Deadline()
}
func (ctx *Context) Done() <-chan struct{} {
return ctx.BaseContext().Done()
}
func (ctx *Context) Err() error {
return ctx.BaseContext().Err()
}
func (ctx *Context) Value(key interface{}) interface{} {
return ctx.BaseContext().Value(key)
}
回复
1个回答

test
2024-06-29
选中struct名称,然后使用快捷键 Ctrl + I on Windows/Linux or ^ + I on macOS
然后会弹出来输入框,你直接输入接口的名称来检索,选中你想要实现的接口,回车就可以啦
可以参考jetbrains的官网说明
回复

适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容