From 8525b20428fdd941303fbebd0e1b1e43dd5f286a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20S=C3=B6derlund?= Date: Wed, 6 May 2020 06:04:40 +0200 Subject: [PATCH] compiler/protogen: add (*GeneratedFile).Unskip Simplifies some compiler plugins who want to avoid generating empty files. With this API, generated files can be skipped by default, and unskipped when actual code is generated. Change-Id: I941c821646f5c4430a84e08bbad7e021434b1e71 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/232239 Reviewed-by: Damien Neil Reviewed-by: Joe Tsai --- compiler/protogen/protogen.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/protogen/protogen.go b/compiler/protogen/protogen.go index 482e8460..b3f7a6ee 100644 --- a/compiler/protogen/protogen.go +++ b/compiler/protogen/protogen.go @@ -1109,6 +1109,12 @@ func (g *GeneratedFile) Skip() { g.skip = true } +// Unskip reverts a previous call to Skip, re-including the generated file in +// the plugin output. +func (g *GeneratedFile) Unskip() { + g.skip = false +} + // Annotate associates a symbol in a generated Go file with a location in a // source .proto file. //