正在生成服务,但没有客户端协议。

huangapple go评论109阅读模式
英文:

Service being generated but not client protoc

问题

我正在使用protoc尝试为我的gRPC服务生成客户端/服务器。

我在我的make文件中有以下内容:

  1. stripe:
  2. @protoc --go_out=. pkg/proto/stripe/service.proto

我的proto文件是

  1. syntax = "proto3";
  2. package grpc;
  3. option go_package = "pkg/proto/stripe/";
  4. service Stripe {
  5. rpc UpdateVerification(UpdateVerificationRequest) returns (UpdateVerificationResponse);
  6. }
  7. message UpdateVerificationRequest {
  8. string id = 1;
  9. }
  10. message UpdateVerificationResponse {
  11. }

当我运行make stripe时,它会生成一个service.pb.go文件,但没有生成接口或客户端。

这是我在生成CLI命令中遗漏的东西吗?

英文:

I am using protoc to try and generate a client / server for my gRPC service.

I have the following in my make file

  1. stripe:
  2. @protoc --go_out=. pkg/proto/stripe/service.proto

My proto file is

  1. syntax = "proto3";
  2. package grpc;
  3. option go_package = "pkg/proto/stripe/";
  4. service Stripe {
  5. rpc UpdateVerification(UpdateVerificationRequest) returns (UpdateVerificationResponse);
  6. }
  7. message UpdateVerificationRequest {
  8. string id = 1;
  9. }
  10. message UpdateVerificationResponse {
  11. }

When I run make stripe it generates a service.pb.go but there is no interface or client generated.

Is this something I am missing in the generation CLI command?

答案1

得分: 1

尝试添加go-grpc_out,例如:

  1. protoc --go_out=. --go-grpc_out=. pkg/proto/stripe/service.proto

这将在与proto文件相同的目录中生成service_grpc.pb.go文件。

根据快速入门指南的建议,完整的命令可以是:

  1. protoc --go_out=. --go_opt=paths=source_relative \
  2. --go-grpc_out=. --go-grpc_opt=paths=source_relative \
  3. pkg/proto/stripe/service.proto
英文:

Try adding go-grpc_out, as example:

  1. protoc --go_out=. --go-grpc_out=. pkg/proto/stripe/service.proto

Will generate also the service_grpc.pb.go file in the same dir of the proto

As suggested in the quickstart giude, the full command could be:

  1. protoc --go_out=. --go_opt=paths=source_relative \
  2. --go-grpc_out=. --go-grpc_opt=paths=source_relative \
  3. pkg/proto/stripe/service.proto

huangapple
  • 本文由 发表于 2021年12月18日 22:03:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/70404055.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定