我想测试一个 Go 编写的 gRPC 服务。我用的例子来自grpc-go repo的 Hello World 服务器示例。 / x/ Y7 U9 H# ^. z0 i3 F4 aprotobuf 定义如下:2 {# C- J% L- S6 p, o6 b. Y( Z
syntax = "proto3";package helloworld;// The greeting service definition.service Greeter { / Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {}/ The request message containing the user's name.message HelloRequest { string name = 1;}// The response message containing the greetingsmessage HelloReply { string message = 1;}3 p! A u) V" V% e; f. U
greeter_server主要类型为:. t4 d t, V# \8 Z1 u' P2 W( P' S
// server is used to implement helloworld.GreeterServer.type server struct{}// SayHello implements helloworld.GreeterServerfunc (s *server) SayHello(ctx context.Context,in *pb.HelloRequest) (*pb.HelloReply,error) return &pb.HelloReply{Message: "Hello " in.Name},nil}) d5 i' u( h6 _4 u