From f867cb5c72244dd495b8755aa7e1cf21c3544a0a Mon Sep 17 00:00:00 2001 From: Gary Burd Date: Sun, 20 Apr 2014 07:20:03 -0700 Subject: [PATCH] Cleanup issues reported by golint. --- conn.go | 15 ++++++++++----- conn_test.go | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/conn.go b/conn.go index de50f64..ccb1f93 100644 --- a/conn.go +++ b/conn.go @@ -61,7 +61,12 @@ var ( ) var ( + // ErrCloseSent is returned when the application writes a message to the + // connection after sending a close message. ErrCloseSent = errors.New("websocket: close sent") + + // ErrReadLimit is returned when reading a message that is larger than the + // read limit set for the connection. ErrReadLimit = errors.New("websocket: read limit exceeded") ) @@ -101,7 +106,7 @@ func isData(frameType int) bool { func maskBytes(key [4]byte, pos int, b []byte) int { for i := range b { b[i] ^= key[pos&3] - pos += 1 + pos++ } return pos & 3 } @@ -302,7 +307,7 @@ func (c *Conn) flushFrame(final bool, extra []byte) error { // Check for invalid control frames. if isControl(c.writeFrameType) && (!final || length > maxControlFramePayloadSize) { - c.writeSeq += 1 + c.writeSeq++ c.writeFrameType = noFrame c.writePos = maxFrameHeaderSize return errInvalidControlFrame @@ -357,7 +362,7 @@ func (c *Conn) flushFrame(final bool, extra []byte) error { c.writePos = maxFrameHeaderSize c.writeFrameType = continuationFrame if final { - c.writeSeq += 1 + c.writeSeq++ c.writeFrameType = noFrame } return c.writeErr @@ -666,7 +671,7 @@ func (c *Conn) read(buf []byte) error { // accessed by more than one goroutine at a time. func (c *Conn) NextReader() (messageType int, r io.Reader, err error) { - c.readSeq += 1 + c.readSeq++ c.readLength = 0 for c.readErr == nil { @@ -703,7 +708,7 @@ func (r messageReader) Read(b []byte) (n int, err error) { } if r.c.readFinal { - r.c.readSeq += 1 + r.c.readSeq++ return 0, io.EOF } diff --git a/conn_test.go b/conn_test.go index 44eeeb7..fcba850 100644 --- a/conn_test.go +++ b/conn_test.go @@ -15,7 +15,7 @@ import ( "time" ) -var timeoutErrImplementsNetError net.Error = errWriteTimeout +var _ net.Error = errWriteTimeout type fakeNetConn struct { io.Reader