go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

How to use gateway to reflect rpc methods?

Open utopiosphe opened this issue 1 year ago • 2 comments

Since I read your tutorial《五分钟给你的 gRPC服务 加上 HTTP 接口 》https://www.cnblogs.com/kevinwan/p/16492868.html, I tried following your instructions, but I encountered some issues and need your help.

Here is my local environment: OS: macOS 13.1 (22C65) Go: go1.19.9 darwin/amd64 goctl: 1.5.2 darwin/amd64 go-zero: v1.5.3

In your tutorial, you mentioned creating a proto file as usual and generating stub files using goctl. Then, modifying the file to import Google's proto and adding option (google.api.http) in the RPC method body. After that, generating a pbset descriptor set file using protoc --include_imports --descriptor_set_out, and finally modifying the startup and configuration files to start the HTTP service mapped by the gateway.

My question is: In a normal zero RPC project, if I modify the proto file as described above, goctl reports errors similar to "Import 'google/api/annotations.proto' was not found or had errors". Can goctl handle generating code with imported third-party protos? In regular development, proto files may be modified frequently, and it seems that your tutorial does not meet my development requirement. Am I using the wrong approach, or could you provide a best practice solution?

我的问题是: 在正常的zero rpc项目中, 如果我修改了proto文件为以上形式, goctl会报Import "google/api/annotations.proto" was not found or had errors 类似的错误, goctl是否能兼容导入第三方proto的生成? 在正常的业务开发中, 可以会频繁的修改proto文件, 现在您的教程似乎无法满足开发的需求. 是否我使用的方式错误, 或者是否能提供一次最佳实践?

utopiosphe avatar May 24 '23 12:05 utopiosphe