I am using trying to create a 2d array in .proto file like this:
message Foo {
repeated int32 items = 1;
}
repeated Foo items= 1;
but on generating the .pb.go file, getting the error for this line repeated Foo items= 1;
Getting Expected top-level statement (e.g. "message")
Has anyone ever came across this error?
Please let me know how could we resolve this issue?
You cannot have a field at the top level, everything should be enclosed in a message or enum. So in your case you should have something like:
Then you will be able to set the items by doing the following:
where pb is the name for the import of the package you defined in your proto file. Eg:
proto:
go: