package main import ( "log" "net" "runtime" proto "edb/goproto" grpc "google.golang.org/grpc" ) const ( port = "20051" ) func CreateServer() { //起服务 listen, err := net.Listen("tcp", "localhost:"+port) if err != nil { log.Fatalf("failed to listen: %v", err) } gserver := grpc.NewServer() proto.RegisterEasyDataServer(gserver, &server{}) gserver.Serve(listen) // time.Sleep(time.Millisecond * 50) } func main() { runtime.GOMAXPROCS(runtime.NumCPU()) // test. CreateServer() }