package main import ( context "context" "edb/goproto" "log" "net" grpc "google.golang.org/grpc" ) // server is used to implement type server struct{} // SayHello implements func (s *server) SayHello(ctx context.Context, in *goproto.Request) (*goproto.Reply, error) { return &goproto.Reply{Msg: "Hello " + in.What, Status: 1, Content: []string{"dasasdasdas"}}, nil } // SayHello implements func (s *server) CreateTable(ctx context.Context, in *goproto.TableRequest) (*goproto.Reply, error) { return &goproto.Reply{Msg: "Create Table " + in.Name, Status: 1, Content: []string{"dasasdasdas"}}, nil } func createTestServer() { //起服务 listen, err := net.Listen("tcp", "localhost:"+port) if err != nil { log.Fatalf("failed to listen: %v", err) } gserver := grpc.NewServer() goproto.RegisterEasyDataServer(gserver, &server{}) goproto.RegisterTestServer(gserver, &server{}) log.Println("create test service : ", port) gserver.Serve(listen) }