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

Function GenerateFileContent

internal/gengogrpc/grpc.go:41–59  ·  view source on GitHub ↗

GenerateFileContent generates the gRPC service definitions, excluding the package statement.

(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile)

Source from the content-addressed store, hash-verified

39
40// GenerateFileContent generates the gRPC service definitions, excluding the package statement.
41func 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
61func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
62 clientName := service.GoName + "Client"

Callers 2

mainFunction · 0.92
GenerateFileFunction · 0.85

Calls 2

genServiceFunction · 0.85
PMethod · 0.45

Tested by

no test coverage detected