go - 使用 GoLand 基于 grpc proto 方法生成 server.go
问题描述
GoLand 中是否有一些功能或插件可以server/server.go
基于 proto rpc 方法生成方法?
例如我们有some.proto
:
...
rpc AnyMetod (AnyRequest) return (AnyResponse)
...
我想生成:
func (s *Server) AnyMethod(ctx context.Context, req *AnyRequest) (*AnyResponse, error) {
return &AnyResponse{}
}
解决方案
目前我不知道有任何可用的插件或功能。
如果您想开发自己的插件,可以从阅读我们的SDK 文档开始。
作为替代方案,我认为您可以使用Live Templates功能来实现与此非常相似的功能,其内容类似于以下示例的行,并将模板定义为可用于“Go | File”上下文:
func (s *$VAR4$) $VAR0$(ctx context.Context, req *$VAR1$) (*$VAR2$, error) {
return &$VAR2${}
}
推荐阅读
- r - 在 R Shiny 中,有没有办法在使用选项“shiny.error”恢复错误时获得反应值?
- artifactory - jfrog.exe 用来与 Artifactory 通信的默认 tcp 端口是什么?
- python - 在 Django 中,如何轻松继承一个字段并使用该字段预配置的参数创建一个新类?
- c - 将各种数据类型的值编码为二进制文件(python),然后在 c 中解码它们
- r - 单元格内有多个逗号的逗号分隔文件
- html - 是否可以在 Power BI 中使用 HTML Viewer Visual 显示动态 iframe 内容?
- javascript - 为什么选项标签中出现 required 属性会影响选项文本的颜色?
- powershell - [环境]::Exit(0) - 这是什么意思?
- php - Drupal always overwrite setting.php file
- python - 如何根据 Latex 格式修复 y 轴标签?