未找到 Protobuf 时间戳 [英] Protobuf timestamp not found

查看:369
本文介绍了未找到 Protobuf 时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GRPC 相对较新,并且在我的 proto 文件中出现了一个我似乎无法理解的错误.我想使用google.protobuf.Timestamp"在消息中发送时间.我似乎无法导入它.我做错了什么?

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;
    }

在我的 IDE 和我的编译器中(使用下面的命令)然后我得到错误

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.

运行命令:

protoc -I profile/ profile/profile.proto --go_out=plugins=grpc:profile

协议 --version

Protoc --version

libprotoc 3.0.0

推荐答案

我遇到了这个问题 - 我已经使用 apt 包管理器 (ubuntu) 安装了 thr protoc 编译器,它把 protoc 编译器放在了类似 /usr 的地方/local/bin 似乎默认情况下 protoc 期望和必需的导入出现在相对于这个 .eg 的包含路径中/usr/local/bin/include/*/usr/local/bin/protoc 旁边.

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.

为了修复,我使用 apt 删除了已安装的版本并从 github 页面下载了最新版本 - github.com/protocolbuffers/protobuf/releases 为您的 os/arch 寻找 protoc 下载(例如 protoc-3.13.0-linux-x86_64.zip)此下载具有所需的包含(在inlcude 文件夹).只需将包含文件夹放在 PATH 中的二进制文件旁边.

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.

这篇关于未找到 Protobuf 时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆