1

Given the following proto spec:

message A {
  B b = 1;
}

message B {
  string s = 1;
}

and an object a of type A, how do I check to see if a.b.s is set? More specifically, how do I create the FieldDescriptor to be passed into Message.Has()?

Noel Yap
  • 18,822
  • 21
  • 92
  • 144

1 Answers1

1

Given some proto object bv := wrapperspb.BoolValue{}, one can get the field descriptor for the value field with fd := (&bv).ProtoReflect().Descriptor().Fields().ByName("value") and check if that field is set with bv.ProtoReflect().Has(fd).

Noel Yap
  • 18,822
  • 21
  • 92
  • 144