【问题标题】:Golang Protoc Compiler Command relative_path problemGolang Protoc Compiler Command relative_path 问题
【发布时间】:2022-01-18 01:41:18
【问题描述】:

我尝试在 golang 中学习 gprc。我编写了一个调用 service.proto 的 .proto 并尝试使用以下命令对其进行编译:

protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative\
proto/service.proto

但我不确定我写的是什么而不是 source_relative。我试图编写“protoc-gen-go.exe”和“protoc-gen-go.exe”包路径,但它抛出了这个错误:

protoc-gen-go: unknown path type "C:/Users/Onur/go/bin": want "import" or "source_relative"

这是我的 .proto 文件:

syntax = "proto3";

package proto;

message Request {
    int64 a = 1;
    int64 b = 2;
}

message Response {
    int64 result = 1;
}

service AddService {
    rpc Add(Request) returns(Response);
    rpc Multiply(Request) returns(Response);
}

【问题讨论】:

    标签: go protocol-buffers grpc proto


    【解决方案1】:

    这个地方的错误:

    --go-grpc_opt=paths=source_relative\
    

    \符号前必须有空格

    试试这个(对我有用):

    protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    proto/service.proto
    

    【讨论】:

      猜你喜欢
      • 2015-09-04
      • 2022-01-18
      • 2011-04-14
      • 2014-10-13
      • 2021-08-23
      • 2021-02-28
      • 2017-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多