Generate generates code for the services in the given file.
(file *generator.FileDescriptor)
| 79 | |
| 80 | // Generate generates code for the services in the given file. |
| 81 | func (g *grpc) Generate(file *generator.FileDescriptor) { |
| 82 | if len(file.FileDescriptorProto.Service) == 0 { |
| 83 | return |
| 84 | } |
| 85 | |
| 86 | contextPkg = string(g.gen.AddImport(contextPkgPath)) |
| 87 | grpcPkg = string(g.gen.AddImport(grpcPkgPath)) |
| 88 | |
| 89 | g.P("// Reference imports to suppress errors if they are not otherwise used.") |
| 90 | g.P("var _ ", contextPkg, ".Context") |
| 91 | g.P("var _ ", grpcPkg, ".ClientConnInterface") |
| 92 | g.P() |
| 93 | |
| 94 | // Assert version compatibility. |
| 95 | g.P("// This is a compile-time assertion to ensure that this generated file") |
| 96 | g.P("// is compatible with the grpc package it is being compiled against.") |
| 97 | g.P("const _ = ", grpcPkg, ".SupportPackageIsVersion", generatedCodeVersion) |
| 98 | g.P() |
| 99 | |
| 100 | for i, service := range file.FileDescriptorProto.Service { |
| 101 | g.generateService(file, service, i) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // GenerateImports generates the import declaration for this file. |
| 106 | func (g *grpc) GenerateImports(file *generator.FileDescriptor) { |
nothing calls this directly
no test coverage detected