refact: fixed go lint

This commit is contained in:
yunlzheng
2020-03-12 14:14:07 +08:00
parent af549b833f
commit aa7dfdd104
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -16,11 +16,13 @@ var upgrader = websocket.Upgrader{
},
}
// Message ...
type Message struct {
MessageType int
Data []byte
}
// Connection ...
type Connection struct {
wsSocket *websocket.Conn
inChan chan *Message
@@ -31,6 +33,7 @@ type Connection struct {
closeChan chan byte
}
// Constructor ...
func Constructor(resp http.ResponseWriter, req *http.Request) (wsConn *Connection, err error) {
wsSocket, err := upgrader.Upgrade(resp, req, nil)
if err != nil {
@@ -96,6 +99,7 @@ ERROR:
CLOSED:
}
// WsClose ...
func (wsConn *Connection) WsClose() {
wsConn.wsSocket.Close()
@@ -107,6 +111,7 @@ func (wsConn *Connection) WsClose() {
}
}
// WsWrite ...
func (wsConn *Connection) WsWrite(messageType int, data []byte) (err error) {
select {
case wsConn.outChan <- &Message{messageType, data}:
@@ -116,6 +121,7 @@ func (wsConn *Connection) WsWrite(messageType int, data []byte) (err error) {
return
}
// WsRead ...
func (wsConn *Connection) WsRead() (msg *Message, err error) {
select {
case msg = <-wsConn.inChan:
+2
View File
@@ -7,6 +7,7 @@ import (
"k8s.io/client-go/tools/remotecommand"
)
// StreamHandler ...
type StreamHandler struct {
WsConn *Connection
ResizeEvent chan remotecommand.TerminalSize
@@ -19,6 +20,7 @@ type xtermMessage struct {
Cols uint16 `json:"cols"`
}
// Next ...
func (handler *StreamHandler) Next() (size *remotecommand.TerminalSize) {
ret := <-handler.ResizeEvent
size = &ret