Add optional feature in protobuf compiler

Fixes error "is a proto3 file that contains optional fields, but code generator protoc-gen-go-ttrpc hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional."

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2024-02-21 13:49:06 -08:00
parent 90d421ee7e
commit 73b6a9156d

View File

@ -18,6 +18,7 @@ package main
import ( import (
"google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/pluginpb"
) )
func main() { func main() {
@ -30,6 +31,7 @@ func main() {
return nil return nil
}, },
}.Run(func(gen *protogen.Plugin) error { }.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
for _, f := range gen.Files { for _, f := range gen.Files {
if !f.Generate { if !f.Generate {
continue continue