英文:
When I'm trying to compile the Protobuf in golang, It's showing '"int" is not defined.'
问题
在编译proto文件时,我遇到了“'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;
}
输出:
test.proto:11:5: "int"未定义。
英文:
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.
答案1
得分: 5
int
在proto3中不是标量类型。您必须使用指定的有效标量值类型之一:
https://developers.google.com/protocol-buffers/docs/proto3#scalar
将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;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论