1:升级到websocket
//升级webSocket协议 ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
2: 读取消息写入到管道
_, message, err := ws.ReadMessage() if err != nil { return } go addData(message) //启动go程处理数据
3:从管道中读取消息
select { case data := <- inChan: works(data,ws) }