Search code examples
angularprotocol-buffersprimeng

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


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 ?


Solution

  • 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.