the proto file I now define is as follows
syntax = "proto2";
message Test1 {}
message Test2 {
required Test1 test1 = 1;
}
message Test3 {
required Test2 test2 = 1;
}
then I will get a go file with the approximate content
type Test3 {
Test2 *Test2
}
type Test2 {
Test1 *Test1
}
type Test1 {}
then when I use it, it will be very troublesome
var test3 = new(Test3)
test3.Test2 = new(Test2) //
test3.Test2.Test1 = new(Test1) //
fmt.Printf(test3.Test2.Test1) //
as shown above, I have to initialize many times in order to use Test1. Because of business problems, there may be four or five levels. This is too troublesome for coding. What I can think of now is that there are two ideas
.- found a way to initialize the pointer itself once and for all.
- find out whether protobuf has a method that does not generate pointers but only structures, or whether protobuf has a function to generate the first idea
but for these two roads are not through, please give us your advice.