From 5b1f63dc985f4a8eb76f4b4e108aa8df894c7393 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 25 Feb 2021 22:11:08 +0300 Subject: [PATCH] support proto3 optional Signed-off-by: Vasiliy Tolstov --- .gitignore | 38 ++++++++++++++++++++++++++++++++++++++ main.go | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b8b0d76 --- /dev/null +++ b/.gitignore @@ -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 + diff --git a/main.go b/main.go index 5ebc2ae..c6c0b97 100644 --- a/main.go +++ b/main.go @@ -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, "|") {