support proto3 optional

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-02-25 22:11:08 +03:00
parent 142f6dd866
commit 5b1f63dc98
2 changed files with 40 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
"strings"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/pluginpb"
)
var (
@@ -36,6 +37,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
g.standalone = *flagStandalone
g.debug = *flagDebug
g.components = *flagComponents
plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
// Protoc passes a slice of File structs for us to process
for _, component := range strings.Split(g.components, "|") {