grpc-go

How to generate _ttrpc.pb.go file from .proto files using protoc command for ttrpc


trying to write a sample grpc using light weight ttrpc repo.

Question is not able to generate _ttrpc.pb.go files from .proto using protoc command.

can anyone help with the code generation from proto files as show in the example here https://github.com/containerd/ttrpc/blob/main/example/example_ttrpc.pb.go


Solution

  • first install the binary protoc-gen-go-ttrpc from source repo

    $ cd ttrpc/cmd/protoc-gen-go-ttrpc
    $ go install

    this will put a binary file protoc-gen-go-ttrpc.exe in %GOBIN% directory

    now in example folder.
    run the following protoc command with ttrpc plugin

     protoc -I ../pb --go_out=. --go_opt=paths=source_relative --go-ttrpc_out=plugins=ttrpc:../pb  ../pb/hello.proto  
    

    this will generate the following files.

    pb
    |__ hello.proto
    |__ hello.pb.go
    |__ hello.ttrpc.pb.go