Complete the code to define a gRPC service method.
service UserService {
rpc GetUser([1]) returns (UserResponse);
}The gRPC method takes a request message as input. Here, UserRequest is the correct input message type.
Complete the code to create a gRPC client stub in Go.
conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { log.Fatalf("did not connect: %v", err) } defer conn.Close() client := [1](conn)
The client stub is created using the generated function NewUserServiceClient with the connection.
Fix the error in the server implementation to register the gRPC service.
grpcServer := grpc.NewServer()
[1](grpcServer, &server{})The correct function to register the service is RegisterUserServiceServer, generated by the gRPC tools.
Fill both blanks to define a unary gRPC method handler signature in Go.
func (s *server) GetUser(ctx context.Context, [1] *UserRequest) (*UserResponse, [2]) { // implementation }
The method takes a request pointer named request and returns a response pointer and an error.
Fill all three blanks to create a gRPC client call and handle the response in Go.
resp, [1] := client.GetUser(context.Background(), &[2]{}) if [3] != nil { log.Fatalf("could not get user: %v", err) } // use resp
The client call returns a response and an error (err). The request message is UserRequest. The error variable is checked to handle failures.