TL;DR: Does golang/protobuf support custom options?
I’m playing around with generating files from .proto files. We have a service written in JS that uses proto files to generate JS objects, and we want to be able to use the same proto files for our Go services.
I can get golang/protobuf working with the example .proto file, which looks like this:
package example;
enum FOO { X = 17; };
message Test {
required string label = 1;
optional int32 type = 2 [default=77];
repeated int64 reps = 3;
optional group OptionalGroup = 4 {
required string RequiredField = 5;
}
}
This file doesn’t have any options or field options other than “default,” which is a built-in field option, I think. (I’m kind of a protobuf noob, so bear with me please.)
Anyways, our preexisting proto files use options and custom field options, kind of like this:
package example;
message Vegetable {
option key = "Vegetable";
optional string vegetable_id = 1;
optional string name = 2 [removed=true];
}
When I try to run protoc on that, I get:
example.proto:7:30: Option "removed" unknown.
example.proto:4:10: Option "key" unknown.
Does that mean that golang/protobuf doesn’t support custom options?
If options are already supported--Is there something else I need to do to add my custom options to get the generator to recognize them?
Or, if they’re not supported and golang/protobuf won’t be able support them anytime soon, does anyone have a good way to add custom options to protos for golang?
Thank you!
Tess