websocket is a minimal and idiomatic WebSocket library for Go.
The library addresses the need for a lightweight WebSocket implementation that integrates naturally with Go's standard patterns. It provides first-class context.Context support, zero dependencies, and passes the WebSocket autobahn-testsuite in full. The implementation offers zero-allocation reads and writes, concurrent writes, and RFC 7692 permessage-deflate compression. Additional capabilities include JSON helpers via a wsjson subpackage, close handshake support, ping-pong functionality, and a net.Conn wrapper for compatibility with code expecting standard network interfaces. The library can compile to WebAssembly.
Developers should choose this library when they need a straightforward WebSocket implementation without external dependencies or when they prefer idiomatic Go APIs. It suits projects ranging from simple real-time communication to full-stack applications, with production examples provided for both echo and chat use cases. Compared to gorilla/websocket, this library trades some features—gorilla offers prepared writes and configurable buffer sizes—for a simpler API and zero dependencies.
The project maintains an active roadmap addressing performance and usability enhancements. Planned work includes assembly-level optimization for WebSocket masking, HTTP/2 support, graceful shutdown helpers, and ping-pong heartbeat utilities. The maintainers track issues systematically and have documented specific enhancement requests with associated issue numbers.