GenerateFileContent generates the gRPC service definitions, excluding the package statement.
(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile)
| 39 | |
| 40 | // GenerateFileContent generates the gRPC service definitions, excluding the package statement. |
| 41 | func GenerateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile) { |
| 42 | if len(file.Services) == 0 { |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | // TODO: Remove this. We don't need to include these references any more. |
| 47 | g.P("// Reference imports to suppress errors if they are not otherwise used.") |
| 48 | g.P("var _ ", contextPackage.Ident("Context")) |
| 49 | g.P("var _ ", grpcPackage.Ident("ClientConnInterface")) |
| 50 | g.P() |
| 51 | |
| 52 | g.P("// This is a compile-time assertion to ensure that this generated file") |
| 53 | g.P("// is compatible with the grpc package it is being compiled against.") |
| 54 | g.P("const _ = ", grpcPackage.Ident("SupportPackageIsVersion6")) |
| 55 | g.P() |
| 56 | for _, service := range file.Services { |
| 57 | genService(gen, file, g, service) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) { |
| 62 | clientName := service.GoName + "Client" |
no test coverage detected