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

Method Generate

protoc-gen-go/grpc/grpc.go:81–103  ·  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

79
80// Generate generates code for the services in the given file.
81func (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.
106func (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