Generate generates code for the services in the given file.
(file *generator.FileDescriptor)
| 103 | |
| 104 | // Generate generates code for the services in the given file. |
| 105 | func (g *grpc) Generate(file *generator.FileDescriptor) { |
| 106 | if len(file.FileDescriptorProto.Service) == 0 { |
| 107 | return |
| 108 | } |
| 109 | |
| 110 | contextPkg = string(g.gen.AddImport(contextPkgPath)) |
| 111 | grpcPkg = string(g.gen.AddImport(grpcPkgPath)) |
| 112 | |
| 113 | g.P("// Reference imports to suppress errors if they are not otherwise used.") |
| 114 | g.P("var _ ", contextPkg, ".Context") |
| 115 | g.P("var _ ", grpcPkg, ".ClientConn") |
| 116 | g.P() |
| 117 | |
| 118 | // Assert version compatibility. |
| 119 | g.P("// This is a compile-time assertion to ensure that this generated file") |
| 120 | g.P("// is compatible with the grpc package it is being compiled against.") |
| 121 | g.P("const _ = ", grpcPkg, ".SupportPackageIsVersion", generatedCodeVersion) |
| 122 | g.P() |
| 123 | |
| 124 | for i, service := range file.FileDescriptorProto.Service { |
| 125 | g.generateService(file, service, i) |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // GenerateImports generates the import declaration for this file. |
| 130 | func (g *grpc) GenerateImports(file *generator.FileDescriptor) {} |
nothing calls this directly
no test coverage detected