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

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
# Develop tools
/.vscode/
/.idea/
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Folders
_obj
_test
_build
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# vim temp files
*~
*.swp
*.swo
/protoc-gen-micro

View File

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