Skip to content

Commit def4f37

Browse files
committed
Clarify docs on Read methods
1 parent e43d9ad commit def4f37

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

websocket.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ import (
2626
//
2727
// Please be sure to call Close on the connection when you
2828
// are finished with it to release the associated resources.
29+
//
30+
// Every error from Read or Reader will cause the connection
31+
// to be closed so you do not need to write your own error message.
32+
// This applies to the Read methods in the wsjson/wspb subpackages as well.
2933
type Conn struct {
3034
subprotocol string
3135
br *bufio.Reader
@@ -311,6 +315,10 @@ func (c *Conn) handleControl(ctx context.Context, h header) error {
311315
// The passed context will also bound the reader.
312316
// Ensure you read to EOF otherwise the connection will hang.
313317
//
318+
// All returned errors will cause the connection
319+
// to be closed so you do not need to write your own error message.
320+
// This applies to the Read methods in the wsjson/wspb subpackages as well.
321+
//
314322
// You must read from the connection for close frames to be read.
315323
// If you do not expect any data messages from the peer, just call
316324
// Reader in a separate goroutine and close the connection with StatusPolicyViolation

0 commit comments

Comments
 (0)