package main
import("context""fmt""github.com/CodisLabs/codis/pkg/utils/log""github.com/golang/protobuf/ptypes/empty""google.golang.org/grpc""grpc-go-study/grpc-other/test_empty/proto""net")const(
port =":50051")type server struct{
proto.UnimplementedGreeterServer
}func(s *server)SayHello1(context.Context,*proto.HelloRequest)(*empty.Empty,error){
fmt.Println("--->this is SayHello1<---")return&empty.Empty{},nil}func(s *server)SayHello2(context.Context,*empty.Empty)(*proto.HelloReply,error){
fmt.Println("--->this is SayHello2<---")return&proto.HelloReply{
Message:"--->this is SayHello2<---",},nil}func(s *server)SayHello3(context.Context,*empty.Empty)(*empty.Empty,error){
fmt.Println("--->this is SayHello3<---")return&empty.Empty{},nil}funcmain(){
lis, err := net.Listen("tcp", port)if err !=nil{
log.Errorf("failed to listen: %v", err)}
s := grpc.NewServer()
proto.RegisterGreeterServer(s,&server{})if err := s.Serve(lis); err !=nil{
log.Errorf("failed to serve: %v", err)}}