Yash Chauhan
Yash Chauhan

Reputation: 366

When I'm trying to compile the Protobuf in golang, It's showing '"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.

Upvotes: 1

Views: 2689

Answers (1)

Yash Chauhan
Yash Chauhan

Reputation: 366

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

Upvotes: 5

Related Questions