相关疑难解决方法(0)

未找到 Protobuf 时间戳

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

    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;
    }
Run Code Online (Sandbox Code Playgroud)

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

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.
Run Code Online (Sandbox Code Playgroud)

运行命令:

protoc -I profile/ profile/profile.proto --go_out=plugins=grpc:profile
Run Code Online (Sandbox Code Playgroud)

协议 --version

libprotoc 3.0.0
Run Code Online (Sandbox Code Playgroud)

protocol-buffers proto grpc

5
推荐指数
3
解决办法
1万
查看次数

标签 统计

grpc ×1

proto ×1

protocol-buffers ×1