使用GoLand基于grpc原型方法生成server.go

时间:2018-08-08 08:36:50

标签: go jetbrains-ide goland

GoLand中是否有一些功能或插件可以基于proto rpc方法生成server/server.go方法?

例如,我们有some.proto

...
rpc AnyMetod (AnyRequest) return (AnyResponse)
...

我想生成:

func (s *Server) AnyMethod(ctx context.Context, req *AnyRequest) (*AnyResponse, error) {
    return &AnyResponse{}
}

1 个答案:

答案 0 :(得分:2)

目前我不知道任何可用的此类插件或功能。

如果您想开发自己的插件,可以先阅读我们的SDK documentation

作为替代方案,我认为您可以使用Live Templates功能来实现与该功能非常相似的功能,其内容与下面的示例类似,并定义可用于“转到|文件”上下文:

func (s *$VAR4$) $VAR0$(ctx context.Context, req *$VAR1$) (*$VAR2$, error) {
    return &$VAR2${}
}