diff --git a/README.md b/README.md index 0827d059..f3e37f4f 100644 --- a/README.md +++ b/README.md @@ -32,33 +32,38 @@ subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn ### Gorilla WebSocket compared with other packages - - - - - - - - - - - - - - - - - -
github.com/gorillagolang.org/x/net
RFC 6455 Features
Passes Autobahn Test SuiteYesNo
Receive fragmented messageYesNo, see note 1
Send close messageYesNo
Send pings and receive pongsYesNo
Get the type of a received data messageYesYes, see note 2
Other Features
Compression ExtensionsExperimentalNo
Read message using io.ReaderYesNo, see note 3
Write message using io.WriteCloserYesNo, see note 3
- -Notes: - -1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html). -2. The application can get the type of a received data message by implementing - a [Codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal) - function. -3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries. - Read returns when the input buffer is full or a frame boundary is - encountered. Each call to Write sends a single frame message. The Gorilla - io.Reader and io.WriteCloser operate on a single WebSocket message. +This comparison used to include [golang.org/x/net/websocket](http://godoc.org/golang.org/x/net/websocket) but it has +been deprecated. Do not use [golang.org/x/net/websocket](http://godoc.org/golang.org/x/net/websocket) in future projects. +See [golang/go#18152](https://github.com/golang/go/issues/18152) + +Another comparison of available Go WebSocket libraries is available at [nhooyr.io/websocket](https://github.com/nhooyr/websocket#comparison) + +#### [nhooyr.io/websocket](https://nhooyr.io/websocket) + +gorilla/websocket is 6 years old and thus very mature and battle tested. On the other hand, it has +accumulated cruft over the years. +[nhooyr.io/websocket](http://godoc.org/nhooyr.io/websocket) is much newer and attempts to +provide a more idiomatic, minimal and useful API for WebSockets. + +| | [github.com/gorilla](http://godoc.org/github.com/gorilla/websocket) | [nhooyr.io/websocket](http://godoc.org/nhooyr.io/websocket) | +| :--- | ---: | ---: | +| **[RFC 6455](http://tools.ietf.org/html/rfc6455) Features** | +| Passes [Autobahn Test Suite](https://github.com/crossbario/autobahn-testsuite) | [Yes](https://github.com/gorilla/websocket/tree/master/examples/autobahn) | [Yes](https://github.com/nhooyr/websocket/blob/master/conn_test.go) | +| Receive [fragmented](https://tools.ietf.org/html/rfc6455#section-5.4) message | Yes | Yes | +| Send [close](https://tools.ietf.org/html/rfc6455#section-5.5.1) message | [Yes](http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages) | [Yes](https://godoc.org/nhooyr.io/websocket#Conn.Close) | +| Send [pings](https://tools.ietf.org/html/rfc6455#section-5.5.2) and receive [pongs](https://tools.ietf.org/html/rfc6455#section-5.5.3) | [Yes](http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages) | [Yes](https://godoc.org/nhooyr.io/websocket#Conn.Ping) +| Get [type](https://tools.ietf.org/html/rfc6455#section-5.6) of received message | Yes | Yes | +| **Other Features** | +| Well tested | Yes | [Yes](https://codecov.io/gh/nhooyr/websocket) | +| Low level protocol control | [Yes](http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages) | No | +| [Compression Extensions](https://tools.ietf.org/html/rfc7692) | [Experimental](https://godoc.org/github.com/gorilla/websocket#hdr-Compression_EXPERIMENTAL) | [No](https://github.com/nhooyr/websocket#design-justifications) | +| Read with [io.Reader](https://golang.org/pkg/io/#Reader) | [Yes](http://godoc.org/github.com/gorilla/websocket#Conn.NextReader) | [Yes](https://godoc.org/nhooyr.io/websocket#Conn.Reader) | +| Write with [io.WriteCloser](https://golang.org/pkg/io/#WriteCloser) | [Yes](http://godoc.org/github.com/gorilla/websocket#Conn.NextWriter) | [Yes](https://godoc.org/nhooyr.io/websocket#Conn.Writer) | +| Compile for [Wasm](https://github.com/golang/go/wiki/WebAssembly) | [No](https://github.com/gorilla/websocket/issues/432) | [Yes](https://godoc.org/nhooyr.io/websocket#hdr-Wasm) | +| Use stdlib [*http.Client](https://golang.org/pkg/net/http/#Client) | No | [Yes](https://godoc.org/nhooyr.io/websocket#DialOptions) | +| Concurrent writers | [No](https://godoc.org/github.com/gorilla/websocket#hdr-Concurrency) | [Yes](https://godoc.org/nhooyr.io/websocket#Conn) | +| Configurable buffer sizes | [Yes](https://godoc.org/github.com/gorilla/websocket#hdr-Buffers) | No | +| Prepared messages | [Yes](https://godoc.org/github.com/gorilla/websocket#PreparedMessage) | No | +| Full [context.Context](https://blog.golang.org/context) support | No | Yes +| [net.Conn](https://golang.org/pkg/net/#Conn) adapter | No | [Yes](https://godoc.org/nhooyr.io/websocket#NetConn) |