()
| 61 | } |
| 62 | |
| 63 | func ExampleCloseStatus() { |
| 64 | // Dials a server and then expects to be disconnected with status code |
| 65 | // websocket.StatusNormalClosure. |
| 66 | |
| 67 | ctx, cancel := context.WithTimeout(context.Background(), time.Minute) |
| 68 | defer cancel() |
| 69 | |
| 70 | c, _, err := websocket.Dial(ctx, "ws://localhost:8080", nil) |
| 71 | if err != nil { |
| 72 | log.Fatal(err) |
| 73 | } |
| 74 | defer c.CloseNow() |
| 75 | |
| 76 | _, _, err = c.Reader(ctx) |
| 77 | if websocket.CloseStatus(err) != websocket.StatusNormalClosure { |
| 78 | log.Fatalf("expected to be disconnected with StatusNormalClosure but got: %v", err) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func Example_writeOnly() { |
| 83 | // This handler demonstrates how to correctly handle a write only WebSocket connection. |
nothing calls this directly
no test coverage detected
searching dependent graphs…