I am building a protoc compiler plugin and I am stuck reading the contents of oneof fields. I have a variable of type descriptorpb.OneofDescriptorProto but I don't know how to get a list of the contained messages. Does someone know how to access this information?
Here is part of the code I use.
- I iterate through the list of protofiles that are provided through stdin.
- In every protofile I iterate the contained messages
- In this case I iterate oneof fields in messages
At that point I do not get the fields contained in oneof fields.
var req pluginpb.CodeGeneratorRequest
proto.Unmarshal(data, &req)
protoFiles := req.ProtoFile
for _, protoFile := range protoFiles {
for _, message := range protoFile.MessageType {
for _, oneof := range message.OneofDecl {
log.Println(*oneof.Name)
}
}
}