Home > Software engineering >  Is there a way to set the first enum value to 1 in protobuf?
Is there a way to set the first enum value to 1 in protobuf?

Time:04-30

The first enum value needs to be 0 in protobuf, but this does some trouble in a dropdown component of Primeng.

Is there a way to set the first enum value to 1 ?

CodePudding user response:

According to the documentation, Protobuf is not allowed to set the first enum value to other value except 0:

As you can see, the Corpus enum's first constant maps to zero: every enum definition must contain a constant that maps to zero as its first element. This is because:

  • There must be a zero value, so that we can use 0 as a numeric default value.
  • The zero value needs to be the first element, for compatibility with the proto2 semantics where the first enum value is always the default.
  • Related