The coder/websocket package is a small Go WebSocket library maintained by Coder, with low-allocation reads and writes and concurrent send support.
Overview
This Go module implements the WebSocket protocol with a deliberately small surface area. It targets idiomatic Go usage alongside net/http servers and clients rather than wrapping a raw net.Conn directly.
The design emphasizes concurrent writes without extra locking at the call site, efficient masking, and a path toward HTTP/2-related improvements noted in the roadmap. Examples include a production-style echo server and a fuller chat demo.
Compared with gorilla/websocket, the authors highlight a slimmer API, native context support, and faster masking. Development succeeded nhooyr/websocket and is actively maintained under the Coder organization.
Developers import the package into Go services or clients that need WebSocket connectivity without pulling in a larger framework.
Key features
- Minimal WebSocket API
- Concurrent safe writes
- Context-aware operations
- Zero-allocation I/O paths
- Server and client examples
- HTTP integration friendly
Use cases
- Go HTTP services with live sockets
- Chat or streaming backends in Go
- Replacing older Go WebSocket stacks