Skip to content

Commit 279a9ea

Browse files
committed
refactor: hard-fork repo for wasm-optimized fork
This is due to the following PR rejection: coder#449 Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent 9fe1a2e commit 279a9ea

38 files changed

Lines changed: 103 additions & 104 deletions

README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
# websocket
22

3-
[![Go Reference](https://pkg.go.dev/badge/github.com/coder/websocket.svg)](https://pkg.go.dev/github.com/coder/websocket)
4-
[![Go Coverage](https://coder.github.io/websocket/coverage.svg)](https://coder.github.io/websocket/coverage.html)
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/paralin/go-websocket.svg)](https://pkg.go.dev/github.com/paralin/go-websocket)
54

65
websocket is a minimal and idiomatic WebSocket library for Go.
76

7+
This is a hard fork of [coder/websocket](https://github.com/coder/websocket) (itself a fork of
8+
[nhooyr/websocket](https://github.com/nhooyr/websocket)). The primary change is avoiding the
9+
`net/http` import to significantly reduce binary size when compiling to WebAssembly. See
10+
[coder/websocket#449](https://github.com/coder/websocket/pull/449) for context.
11+
812
## Install
913

1014
```sh
11-
go get github.com/coder/websocket
15+
go get github.com/paralin/go-websocket
1216
```
1317

14-
> [!NOTE]
15-
> Coder now maintains this project as explained in [this blog post](https://coder.com/blog/websocket).
16-
> We're grateful to [nhooyr](https://github.com/nhooyr) for authoring and maintaining this project from
17-
> 2019 to 2024.
18-
1918
## Highlights
2019

2120
- Minimal and idiomatic API
2221
- First class [context.Context](https://blog.golang.org/context) support
2322
- Fully passes the WebSocket [autobahn-testsuite](https://github.com/crossbario/autobahn-testsuite)
24-
- [Zero dependencies](https://pkg.go.dev/github.com/coder/websocket?tab=imports)
25-
- JSON helpers in the [wsjson](https://pkg.go.dev/github.com/coder/websocket/wsjson) subpackage
23+
- [Zero dependencies](https://pkg.go.dev/github.com/paralin/go-websocket?tab=imports)
24+
- JSON helpers in the [wsjson](https://pkg.go.dev/github.com/paralin/go-websocket/wsjson) subpackage
2625
- Zero alloc reads and writes
2726
- Concurrent writes
28-
- [Close handshake](https://pkg.go.dev/github.com/coder/websocket#Conn.Close)
29-
- [net.Conn](https://pkg.go.dev/github.com/coder/websocket#NetConn) wrapper
30-
- [Ping pong](https://pkg.go.dev/github.com/coder/websocket#Conn.Ping) API
27+
- [Close handshake](https://pkg.go.dev/github.com/paralin/go-websocket#Conn.Close)
28+
- [net.Conn](https://pkg.go.dev/github.com/paralin/go-websocket#NetConn) wrapper
29+
- [Ping pong](https://pkg.go.dev/github.com/paralin/go-websocket#Conn.Ping) API
3130
- [RFC 7692](https://tools.ietf.org/html/rfc7692) permessage-deflate compression
32-
- [CloseRead](https://pkg.go.dev/github.com/coder/websocket#Conn.CloseRead) helper for write only connections
33-
- Compile to [Wasm](https://pkg.go.dev/github.com/coder/websocket#hdr-Wasm)
31+
- [CloseRead](https://pkg.go.dev/github.com/paralin/go-websocket#Conn.CloseRead) helper for write only connections
32+
- Compile to [Wasm](https://pkg.go.dev/github.com/paralin/go-websocket#hdr-Wasm)
3433

3534
## Roadmap
3635

@@ -110,36 +109,36 @@ Advantages of [gorilla/websocket](https://github.com/gorilla/websocket):
110109
- [Prepared writes](https://pkg.go.dev/github.com/gorilla/websocket#PreparedMessage)
111110
- Configurable [buffer sizes](https://pkg.go.dev/github.com/gorilla/websocket#hdr-Buffers)
112111

113-
Advantages of github.com/coder/websocket:
112+
Advantages of this library (and [coder/websocket](https://github.com/coder/websocket)):
114113

115114
- Minimal and idiomatic API
116-
- Compare godoc of [github.com/coder/websocket](https://pkg.go.dev/github.com/coder/websocket) with [gorilla/websocket](https://pkg.go.dev/github.com/gorilla/websocket) side by side.
117-
- [net.Conn](https://pkg.go.dev/github.com/coder/websocket#NetConn) wrapper
115+
- Compare godoc of [github.com/paralin/go-websocket](https://pkg.go.dev/github.com/paralin/go-websocket) with [gorilla/websocket](https://pkg.go.dev/github.com/gorilla/websocket) side by side.
116+
- [net.Conn](https://pkg.go.dev/github.com/paralin/go-websocket#NetConn) wrapper
118117
- Zero alloc reads and writes ([gorilla/websocket#535](https://github.com/gorilla/websocket/issues/535))
119118
- Full [context.Context](https://blog.golang.org/context) support
120119
- Dial uses [net/http.Client](https://golang.org/pkg/net/http/#Client)
121120
- Will enable easy HTTP/2 support in the future
122121
- Gorilla writes directly to a net.Conn and so duplicates features of net/http.Client.
123122
- Concurrent writes
124123
- Close handshake ([gorilla/websocket#448](https://github.com/gorilla/websocket/issues/448))
125-
- Idiomatic [ping pong](https://pkg.go.dev/github.com/coder/websocket#Conn.Ping) API
124+
- Idiomatic [ping pong](https://pkg.go.dev/github.com/paralin/go-websocket#Conn.Ping) API
126125
- Gorilla requires registering a pong callback before sending a Ping
127126
- Can target Wasm ([gorilla/websocket#432](https://github.com/gorilla/websocket/issues/432))
128-
- Transparent message buffer reuse with [wsjson](https://pkg.go.dev/github.com/coder/websocket/wsjson) subpackage
127+
- Transparent message buffer reuse with [wsjson](https://pkg.go.dev/github.com/paralin/go-websocket/wsjson) subpackage
129128
- [1.75x](https://github.com/nhooyr/websocket/releases/tag/v1.7.4) faster WebSocket masking implementation in pure Go
130129
- Gorilla's implementation is slower and uses [unsafe](https://golang.org/pkg/unsafe/).
131130
Soon we'll have assembly and be 3x faster [#326](https://github.com/nhooyr/websocket/pull/326)
132131
- Full [permessage-deflate](https://tools.ietf.org/html/rfc7692) compression extension support
133132
- Gorilla only supports no context takeover mode
134-
- [CloseRead](https://pkg.go.dev/github.com/coder/websocket#Conn.CloseRead) helper for write only connections ([gorilla/websocket#492](https://github.com/gorilla/websocket/issues/492))
133+
- [CloseRead](https://pkg.go.dev/github.com/paralin/go-websocket#Conn.CloseRead) helper for write only connections ([gorilla/websocket#492](https://github.com/gorilla/websocket/issues/492))
135134

136135
#### golang.org/x/net/websocket
137136

138137
[golang.org/x/net/websocket](https://pkg.go.dev/golang.org/x/net/websocket) is deprecated.
139138
See [golang/go/issues/18152](https://github.com/golang/go/issues/18152).
140139

141-
The [net.Conn](https://pkg.go.dev/github.com/coder/websocket#NetConn) can help in transitioning
142-
to github.com/coder/websocket.
140+
The [net.Conn](https://pkg.go.dev/github.com/paralin/go-websocket#NetConn) can help in transitioning
141+
to this library.
143142

144143
#### gobwas/ws
145144

@@ -148,7 +147,7 @@ in an event driven style for performance. See the author's [blog post](https://m
148147

149148
However it is quite bloated. See https://pkg.go.dev/github.com/gobwas/ws
150149

151-
When writing idiomatic Go, github.com/coder/websocket will be faster and easier to use.
150+
When writing idiomatic Go, this library will be faster and easier to use.
152151

153152
#### lesismal/nbio
154153

@@ -157,4 +156,4 @@ event driven for performance reasons.
157156

158157
However it is quite bloated. See https://pkg.go.dev/github.com/lesismal/nbio
159158

160-
When writing idiomatic Go, github.com/coder/websocket will be faster and easier to use.
159+
When writing idiomatic Go, this library will be faster and easier to use.

accept.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"path"
1818
"strings"
1919

20-
"github.com/coder/websocket/internal/errd"
20+
"github.com/paralin/go-websocket/internal/errd"
2121
)
2222

2323
// AcceptOptions represents Accept's options.

accept_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"sync"
1313
"testing"
1414

15-
"github.com/coder/websocket/internal/test/assert"
16-
"github.com/coder/websocket/internal/test/xrand"
15+
"github.com/paralin/go-websocket/internal/test/assert"
16+
"github.com/paralin/go-websocket/internal/test/xrand"
1717
)
1818

1919
func TestAccept(t *testing.T) {

autobahn_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import (
1616
"testing"
1717
"time"
1818

19-
"github.com/coder/websocket"
20-
"github.com/coder/websocket/internal/errd"
21-
"github.com/coder/websocket/internal/test/assert"
22-
"github.com/coder/websocket/internal/test/wstest"
23-
"github.com/coder/websocket/internal/util"
19+
"github.com/paralin/go-websocket"
20+
"github.com/paralin/go-websocket/internal/errd"
21+
"github.com/paralin/go-websocket/internal/test/assert"
22+
"github.com/paralin/go-websocket/internal/test/wstest"
23+
"github.com/paralin/go-websocket/internal/util"
2424
)
2525

2626
var excludedAutobahnCases = []string{

close.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net"
1111
"time"
1212

13-
"github.com/coder/websocket/internal/errd"
13+
"github.com/paralin/go-websocket/internal/errd"
1414
)
1515

1616
// StatusCode represents a WebSocket status code.

close_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"testing"
1010

11-
"github.com/coder/websocket/internal/test/assert"
11+
"github.com/paralin/go-websocket/internal/test/assert"
1212
)
1313

1414
func TestCloseError(t *testing.T) {

compress_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"testing"
1414
"time"
1515

16-
"github.com/coder/websocket/internal/test/assert"
17-
"github.com/coder/websocket/internal/test/xrand"
16+
"github.com/paralin/go-websocket/internal/test/assert"
17+
"github.com/paralin/go-websocket/internal/test/xrand"
1818
)
1919

2020
func Test_slidingWindow(t *testing.T) {
@@ -67,7 +67,7 @@ func BenchmarkFlateReader(b *testing.B) {
6767
// TestWriteSingleFrameCompressed verifies that Conn.Write sends compressed
6868
// messages in a single frame instead of multiple frames, and that messages
6969
// below the flateThreshold are sent uncompressed.
70-
// This is a regression test for https://github.com/coder/websocket/issues/435
70+
// This is a regression test for https://github.com/paralin/go-websocket/issues/435
7171
func TestWriteSingleFrameCompressed(t *testing.T) {
7272
t.Parallel()
7373

conn_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import (
1717
"testing"
1818
"time"
1919

20-
"github.com/coder/websocket"
21-
"github.com/coder/websocket/internal/errd"
22-
"github.com/coder/websocket/internal/test/assert"
23-
"github.com/coder/websocket/internal/test/wstest"
24-
"github.com/coder/websocket/internal/test/xrand"
25-
"github.com/coder/websocket/internal/xsync"
26-
"github.com/coder/websocket/wsjson"
20+
"github.com/paralin/go-websocket"
21+
"github.com/paralin/go-websocket/internal/errd"
22+
"github.com/paralin/go-websocket/internal/test/assert"
23+
"github.com/paralin/go-websocket/internal/test/wstest"
24+
"github.com/paralin/go-websocket/internal/test/xrand"
25+
"github.com/paralin/go-websocket/internal/xsync"
26+
"github.com/paralin/go-websocket/wsjson"
2727
)
2828

2929
func TestConn(t *testing.T) {

dial.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"sync"
1717
"time"
1818

19-
"github.com/coder/websocket/internal/errd"
19+
"github.com/paralin/go-websocket/internal/errd"
2020
)
2121

2222
// DialOptions represents Dial's options.

dial_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
"testing"
1616
"time"
1717

18-
"github.com/coder/websocket"
19-
"github.com/coder/websocket/internal/test/assert"
20-
"github.com/coder/websocket/internal/util"
21-
"github.com/coder/websocket/internal/xsync"
18+
"github.com/paralin/go-websocket"
19+
"github.com/paralin/go-websocket/internal/test/assert"
20+
"github.com/paralin/go-websocket/internal/util"
21+
"github.com/paralin/go-websocket/internal/xsync"
2222
)
2323

2424
func TestBadDials(t *testing.T) {

0 commit comments

Comments
 (0)