当我试图在Golang中编译Protobuf时,它显示了“ int”未定义。'

发布于 2025-02-12 06:24:23 字数 390 浏览 0 评论 0 原文

在编译原始文件时,我得到的“ int”不是定义的'。

'test.proto'文件

syntax = "proto3";

package test;

option go_package = "/;test";

message User {
    string FirstName = 1;
    string LastName = 2;
    string Address = 3;
    int Contact = 4;
    int Age = 5;
}
Output:
test.proto:11:5: "int" is not defined.

While compiling the proto file, I'm getting '"int" is not defined'.

'test.proto' file

syntax = "proto3";

package test;

option go_package = "/;test";

message User {
    string FirstName = 1;
    string LastName = 2;
    string Address = 3;
    int Contact = 4;
    int Age = 5;
}
Output:
test.proto:11:5: "int" is not defined.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似狗非友 2025-02-19 06:24:24

int 不是proto3中的标量类型。您必须使用指定的有效标量值类型之一:

Replacing int 带有 int32

syntax = "proto3";

package test;

option go_package = "/;test";

message User {
    string FirstName = 1;
    string LastName = 2;
    string Address = 3;
    int32 Contact = 4;
    int32 Age = 5;
}

int is not a scalar type in proto3. You must use one of the valid scalar value types as specified:

https://developers.google.com/protocol-buffers/docs/proto3#scalar

Replacing int with int32:

syntax = "proto3";

package test;

option go_package = "/;test";

message User {
    string FirstName = 1;
    string LastName = 2;
    string Address = 3;
    int32 Contact = 4;
    int32 Age = 5;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文