Code generation from proto files

I am trying to generate code in pb dir (which I have created already) form proto files. The command I am using is as follows

protoc --proto_path=proto proto/*.proto --go_out=pb --go-grpc_out=pb

I am getting error

2021/03/18 11:34:46 WARNING: Deprecated use of 'go_package' option without a full import path in "laptop_service.proto", please specify:
                option go_package = ".;pb";
        A future release of protoc-gen-go will require the import path be specified.
        See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
        protoc-gen-go-grpc: invalid Go import path "pb" for "keyboard.proto"
        The import path must contain at least one forward slash ('/') character.
        See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
        --go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1.

In proto file I have
option go_package = "pb";
what I am doing wrong ?

As the error says your option go_pachage must contain at least one forward slash (/).
Try something like:

  • option go_package = "./pb"; or
  • option go_package = "/pb";

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.