Search code examples
goprotocol-buffersproto

WARNING: Missing 'go_package' option


Im getting the following error once i run the protocol command to generate pb.go file But I can generate the pb.go file. how do I mitigate the following error

Missing 'go_package' option in "job.proto",
please specify it with the full Go package path as
a future release of protoc-gen-go will require this be specified.

Solution

  • "Import path" is the path another package would use to import the generated code, e.g. github.com/me/myproject/model or You can simply define the import path based on your preference.

    You can simply define your optional import path as follows

    option go_package = ".;<Your_Import_path>";
    

    For example, we can assume the package path as "/pub", So the statement as follows.

    option go_package = ".;pub";
    

    Then you can simply execute the protoc command to generate the pb.go file

    protoc -I=<ABS_PATH_OUTPUT_DIR> --go_out=<ABS_PATH_PROTO_FILE>