登录
首页 >  Golang >  Go问答

Golang - 找不到google/protobuf/Empty.proto文件

来源:stackoverflow

时间:2024-02-14 20:27:18 336浏览 收藏

golang学习网今天将给大家带来《Golang - 找不到google/protobuf/Empty.proto文件》,感兴趣的朋友请继续看下去吧!以下内容将会涉及到等等知识点,如果你是正在学习Golang或者已经是大佬级别了,都非常欢迎也希望大家都能给我建议评论哈~希望能帮助到大家!

问题内容

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) {}  
}

上面是我的原型文件。我收到错误 google/protobuf/empty.proto: 文件未找到。 当尝试编译上面的 proto 文件时。有人可以帮助我吗?


正确答案


我遇到了同样的问题,因为我没有正确安装协议

要成功安装,请执行以下步骤:

  1. 从此处下载最新版本 https://github.com/protocolbuffers/protobuf/releases
  2. 提取到计算机中
  3. 将 bin/protoc 移动到 /usr/local/bin
sudo mv {downloaded_directory}/bin/protoc /usr/local/bin
  1. 将包含文件夹移动到 /usr/local
sudo mv {downloaded_directory}/include /usr/local

本篇关于《Golang - 找不到google/protobuf/Empty.proto文件》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于Golang的相关知识,请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>