Merge pull request #112 from kzys/skip-empty-go-file

Only generate a Go file if the file has some services
This commit is contained in:
Maksym Pavlenko 2022-04-19 18:48:43 -07:00 committed by GitHub
commit 944ef4a40d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,6 +91,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())