1

After running protoc command I'm getting below error.


google/protobuf/descriptor.proto: File not found.

google/api/annotations.proto: Import "google/protobuf/descriptor.proto" was not found or had errors. google/api/annotations.proto:28:8: "google.protobuf.MethodOptions" is not defined. currency.proto: Import "google/api/annotations.proto" was not found or had errors.

My protoc version is - libprotoc 3.0.0

Here is my proto file code..

syntax = "proto3";

import "google/api/annotations.proto";

service Currency {
    // GetRate returns the exchange rate for the two provided currency codes 
    rpc GetRate(RateRequest) returns (RateResponse) {
        option (google.api.http) = {
            post: "/v1/convert",
            body:"*"
        };
    };
} 
....
....

My directory structure is.. enter image description here

I'm running below command - protoc -I proto/ proto/*.proto --go_out=plugins=grpc:pb

It works fine if I remove the import of google/api/annotations.proto and option... but when I import the google/api/annotations.proto and compile it using protoc, it gives me error.

1 Answer 1

2

annotations.proto is defined in google/api in Google's Google APIs repo.

You'll need to clone that repo/folder and then add it to the --proto_path to protoc compile the proto:

git clone [email protected]:googleapis/googleapis.git

protoc \
--proto_path=proto/ \
--proto_path=googleapis \
--go_out=plugins=grpc:pb \
proto/*.proto
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.