MCPcopy
hub / github.com/gogo/protobuf / Generate

Method Generate

protoc-gen-gogo/grpc/grpc.go:105–127  ·  view source on GitHub ↗

Generate generates code for the services in the given file.

(file *generator.FileDescriptor)

Source from the content-addressed store, hash-verified

103
104// Generate generates code for the services in the given file.
105func (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.
130func (g *grpc) GenerateImports(file *generator.FileDescriptor) {}

Callers

nothing calls this directly

Calls 3

PMethod · 0.95
generateServiceMethod · 0.95
AddImportMethod · 0.80

Tested by

no test coverage detected