1
syntax = "proto3";

package model;

import "google/protobuf/Empty.proto";

message User {
    string id = 1;
    string name  = 2;
    string email = 3;
    string alamat = 4;
    string password = 5;
}

message UserList {
    repeated User list = 1;
}

message userId {
    string id = 1; 
}

message UserUpdate {
    string id = 1;
    User user = 2;
}

service Users {
    rpc getUserList(google.protobuf.Empty) returns (UserList) {}
    rpc getUserById(userId) returns (User) {}
    rpc inserUser(User) returns (google.protobuf.Empty) {}
    rpc updateUser(UserUpdate) returns (google.protobuf.Empty) {} 
    rpc deleteUser(userId) returns (google.protobuf.Empty) {}  
}

above is my proto file. I get error google/protobuf/Empty.proto: File not found. when trying to compile the proto file above. can someone help me ?

Yahfi Ilham
  • 79
  • 2
  • 7

4 Answers4

1

First of all, the correct import is import "google/protobuf/empty.proto";

second, for generating a proto file run this code:

protoc --proto_path={proto_directory_address} --proto_path={proto_directory_name} --go-grpc_out={generated_directory_path} --go_out={generated_directory_path} {proto_directory_address}/{proto_file_name}.proto

ttrasn
  • 4,322
  • 4
  • 26
  • 43
0

hi there / i had the same issue for a long time .. this process worked for me i hope it dose for you too : navigate to this directory using your cmd(command line) :

cd .local/include

this directory normally should contain some folder named "google" copy this folder and paste it to this directory :

/usr/local/include

and now try the protoc engine again to generate your project and if the error still exists then try the rest of process :

navigate to that specific directory and check if its been copied or not . if it is then try to navigate to the folder from where you are (which it should be /usr/local/include) if the error says you have no permission to get in the folder use this command to get the permission

$ sudo chmod o+r -R ./google

and then try to get permission to get in protobuf folder in the same directory using above command again when its all done . check the protoc generator again /// hope works for you because it dose for me

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 04 '23 at 16:40
0

I had the same problem because I had not installed the protoc correctly

For successful installation do these steps:

  1. Download latest version from here https://github.com/protocolbuffers/protobuf/releases
  2. Extract in your computer
  3. move bin/protoc to /usr/local/bin
sudo mv {downloaded_directory}/bin/protoc /usr/local/bin
  1. move include folder to /usr/local
sudo mv {downloaded_directory}/include /usr/local
morteza khadem
  • 346
  • 3
  • 8
-2

import public "google/protobuf/empty.proto";

fauzi
  • 1