'Golang - google/protobuf/Empty.proto: File not found

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 ?



Solution 1:[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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ttrasn