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:"*"
};
};
}
....
....
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.
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 git@github.com:googleapis/googleapis.git
protoc \
--proto_path=proto/ \
--proto_path=googleapis \
--go_out=plugins=grpc:pb \
proto/*.proto
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.