Protobuf "oneof" functionality not working

I have this protobuf sample message:

message testMessage{ oneof oneOfTest{ string test2 = 2; int32 test3 = 3; } } 

But it does not compile, saying:

 [ERROR] protoc failed error: Expected "required", "optional", or "repeated". test.proto: Missing field number. 

According to line numbers, he searches for the required / optional / repeated keyworkd before "oneof", and he complains about the desired field number after "oneOfTest". Isn't that the right way to use one? I am using java compiler for Protobuf.

+5
source share
1 answer

Make sure you are using the latest version of the protocol buffer compiler: the oneof syntax was only added to the most recent version released last Monday.

+9
source

Source: https://habr.com/ru/post/1201659/


All Articles