From 638c688a89a2c8ee731db5b3acb3dd92289751e2 Mon Sep 17 00:00:00 2001 From: lixiangyang Date: Thu, 25 Jul 2024 20:54:24 +0800 Subject: [PATCH] feat: add started chan --- server/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/server.go b/server/server.go index ae2093ce..bbccad3f 100644 --- a/server/server.go +++ b/server/server.go @@ -129,6 +129,9 @@ type Server struct { ServerErrorFunc func(res *protocol.Message, err error) string ViewManager *ViewManager + + // The server is started. + Started chan struct{} } // NewServer returns a server. @@ -141,6 +144,7 @@ func NewServer(options ...OptionFn) *Server { serviceMap: make(map[string]*service), router: make(map[string]Handler), AsyncWrite: false, // 除非你想做进一步的优化测试,否则建议你设置为false + Started: make(chan struct{}), } for _, op := range options { @@ -268,6 +272,7 @@ func (s *Server) serveListener(ln net.Listener) error { s.mu.Lock() s.ln = ln + close(s.Started) s.mu.Unlock() for {