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

Method generateServerMethodConcrete

protoc-gen-go/grpc/grpc.go:279–291  ·  view source on GitHub ↗

generateServerMethodConcrete returns unimplemented methods which ensure forward compatibility

(servName string, method *pb.MethodDescriptorProto)

Source from the content-addressed store, hash-verified

277
278// generateServerMethodConcrete returns unimplemented methods which ensure forward compatibility
279func (g *grpc) generateServerMethodConcrete(servName string, method *pb.MethodDescriptorProto) {
280 header := g.generateServerSignatureWithParamNames(servName, method)
281 g.P("func (*Unimplemented", servName, "Server) ", header, " {")
282 var nilArg string
283 if !method.GetServerStreaming() && !method.GetClientStreaming() {
284 nilArg = "nil, "
285 }
286 methName := generator.CamelCase(method.GetName())
287 statusPkg := string(g.gen.AddImport(statusPkgPath))
288 codePkg := string(g.gen.AddImport(codePkgPath))
289 g.P("return ", nilArg, statusPkg, `.Errorf(`, codePkg, `.Unimplemented, "method `, methName, ` not implemented")`)
290 g.P("}")
291}
292
293// generateClientSignature returns the client-side signature for a method.
294func (g *grpc) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string {

Callers 1

Calls 5

PMethod · 0.95
CamelCaseFunction · 0.92
AddImportMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected