Only generate a Go file if the file has some services
Otherwise, this generator creates a Go file with some import statements, that causes "imported and not used" error. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
parent
aa5c94700b
commit
f0fda535e2
@ -58,6 +58,11 @@ func newGenerator(out *protogen.GeneratedFile) *generator {
|
||||
}
|
||||
|
||||
func generate(plugin *protogen.Plugin, input *protogen.File) error {
|
||||
if len(input.Services) == 0 {
|
||||
// Only generate a Go file if the file has some services.
|
||||
return nil
|
||||
}
|
||||
|
||||
file := plugin.NewGeneratedFile(input.GeneratedFilenamePrefix+"_ttrpc.pb.go", input.GoImportPath)
|
||||
file.P("// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.")
|
||||
file.P("// source: ", input.Desc.Path())
|
||||
|
Loading…
Reference in New Issue
Block a user