gorilla/websocket 报错concurrent w
2021-01-11 本文已影响0人
yichen_china
https://sourcegraph.com/github.com/gorilla/websocket@master/-/blob/conn_test.go#L222:16
type WsConn struct {
*websocket.Conn
Mux sync.RWMutex
}
wsConn.Mux.Lock() //加锁
err=wsConn.Conn.WriteMessage(websocket.TextMessage,msgByte)
wsConn.Mux.Unlock() //解锁