ws is a WebSocket library for Go that implements RFC6455.
The library addresses the problem of buffer reuse across WebSocket connections, which existing implementations do not support clearly. It provides a low-level API that allows developers to control packet handling and reuse buffers between connections without forcing a single usage pattern. For developers who prefer not to work directly with the protocol, the wsutil package offers higher-level wrappers and helpers that enable quick setup without deep protocol knowledge.
The tool suits high-load services that need to manage many concurrent connections and control resource allocation carefully. The zero-copy upgrade mechanism eliminates intermediate allocations during the HTTP upgrade handshake by processing non-WebSocket headers in place using registered callbacks. Developers choosing between abstraction levels can use the low-level API for maximum control or the wsutil package for convenience. The library also includes wsflate for Permessage-Deflate compression support, compatible with both low-level and high-level usage patterns.
The project maintains API stability through semantic versioning, with the v1 tag guaranteeing no breaking changes during improvements or refactoring. The implementation passes the Autobahn Test Suite for RFC6455 compliance. Example applications are maintained in a separate repository to demonstrate usage patterns across different abstraction levels.