Closed
Description
Hello,
I'm trying to loop each field of a message and check proto field option. For example,
rval := reflect.Value(m)
...
_, descProt := descriptor.ForMessage(m)
for _, fd := range d.GetField() {
// check the field option
opts := fd.GetOptions()
c, err := proto.GetExtension(opts, xxx)
...
if condition {
field := rval.FieldByName(fd.GetName() ???)
}
}
Here, fd.GetName()
returns the proto field name, so we need to convert to Go name.
Should I use https://github.com/golang/protobuf/blob/master/protoc-gen-go/generator/generator.go#L2736 ? Or is there any better way to do that?
Thanks,