Relatively new to GRPC and getting an error in my proto file that I cannot seem to make sense of. I would like to send a time in a message using the "google.protobuf.Timestamp". I cannot seem to import it. What am I doing wrong?
syntax = "proto3";
import "google/protobuf/timestamp.proto";
service ProfileService {
rpc ConstructProfileStructFromUser (ConstructProfileStructFromUserRequest) returns (ConstructProfileStructFromUserResponse);
}
message ConstructProfileStructFromUserRequest {
string transactionID = 1;
string User = 2;
}
message ConstructProfileStructFromUserResponse {
string UID = 1;
string ContactEmail = 2;
google.protobuf.Timestamp DateOfBirth = 3;
}
Both in my IDE and my compiler (using the below command) then I get the error
google/protobuf/timestamp.proto: File not found.
profile.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.
profile.proto:21:5: "google.protobuf.Timestamp" is not defined.
Command to run:
protoc -I profile/ profile/profile.proto --go_out=plugins=grpc:profile
Protoc --version
libprotoc 3.0.0
I had this issue - I had installed thr protoc compiler using the apt package manager (ubuntu) and it put the protoc compiler in somewhere like /usr/local/bin
it seems by default protoc expects and required imports to be present in an include path relative to this .e.g. /usr/local/bin/include/*
next to /usr/local/bin/protoc
.
To fix I removed the installed version with apt and downloaded the latest release from the github page - github.com/protocolbuffers/protobuf/releases look for the protoc download for your os/arch (e.g protoc-3.13.0-linux-x86_64.zip
) this download has the required include (in the inlcude
folder). Just place the include folder next to the binary in your PATH.