代码之家  ›  专栏  ›  技术社区  ›  geostocker

无法从我的课程中找出缺少的protoc命令

  •  2
  • geostocker  · 技术社区  · 8 年前

    问题:

    上周左右,我在Udemy上参加了一个Golang microservices课程,遇到了一个问题。

    protoc protoc greeter.proto go_out=. 我错过了比赛 片段。。

    pb.go文件看起来与 the instructor's ,在pb.go文件中包含客户端和服务器代码段。

    缺少客户端代码段。

    protoc greeter.proto go_out=。

    代码:

    .proto文件:

    syntax = "proto3";
    
    service Greeter { 
        rpc Hello(HelloRequest) returns (HelloResponse) {}
    }
    
    message HelloRequest {
        string name = 1;
    }
    
    message HelloResponse {
        string greeting = 2;
    }
    
    2 回复  |  直到 8 年前
        1
  •  0
  •   Bert Verhees    8 年前

    我使用以下命令:

    protoc --proto_path=$GOPATH/src:. --micro_out=. --go_out=plugins=grpc:. *.proto 
    

    从原始文件所在的目录。它生成服务和客户机代码。我在go micro github存储库和go micro网站的众多示例中发现了这个命令。

    然而,这是用于grpc的,但是这个想法是好的。

        2
  •  0
  •   Black_Dreams    7 年前

    希望这有助于:

    # Generate proto
    protoc -I/usr/local/include -I.  -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=google/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. filename.proto
    
    #Reverse Proxy For REST
    protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:. filename.proto
    
    推荐文章