{"id":22867275,"url":"https://github.com/simonfxr/wszero","last_synced_at":"2026-02-13T13:02:15.681Z","repository":{"id":246773749,"uuid":"822727855","full_name":"simonfxr/wszero","owner":"simonfxr","description":"A high-performance, lightweight WebSocket library for Go.","archived":false,"fork":false,"pushed_at":"2024-08-28T11:49:39.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-09T06:41:00.696Z","etag":null,"topics":["fast","go","golang","rfc6455","websocket","websockets"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonfxr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-01T17:39:41.000Z","updated_at":"2024-08-28T11:49:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"d16ac2a0-34de-451f-9f25-52c815f05b5e","html_url":"https://github.com/simonfxr/wszero","commit_stats":null,"previous_names":["simonfxr/wszero"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/simonfxr/wszero","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonfxr%2Fwszero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonfxr%2Fwszero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonfxr%2Fwszero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonfxr%2Fwszero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonfxr","download_url":"https://codeload.github.com/simonfxr/wszero/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonfxr%2Fwszero/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29407032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fast","go","golang","rfc6455","websocket","websockets"],"created_at":"2024-12-13T12:20:15.470Z","updated_at":"2026-02-13T13:02:15.650Z","avatar_url":"https://github.com/simonfxr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lightweight WebSocket Library for Go\n\nThis is a high-performance, lightweight WebSocket library for Go.\n\n## Features\n\n- High performance, usually several times faster than other tested libraries (see below)\n- Zero allocations\n- Zero copy [writev](https://pkg.go.dev/net#Buffers) path when writing fragments \n- Support for both client and server implementations\n- Customizable buffer pool for efficient memory management\n- High level API heavily inspired by the popular [gorilla/websocket](https://github.com/gorilla/websocket)\n- No third party dependencies\n- Tested with [autobahn-testsuite](https://github.com/crossbario/autobahn-testsuite)\n\n## Missing features\n\n- UTF-8 validation of text messages, this can be handled at the application layer\n- WebSocket compression\n\n## Installation\n\nTo install the library, use `go get`:\n\n```bash\ngo get github.com/simonfxr/wszero\n```\n\n## Quick Start\n\n### Server Example\n\nHere's a simple example of how to create a WebSocket server:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/simonfxr/wszero\"\n)\n\nfunc main() {\n\tupgrader := \u0026wszero.Upgrader{}\n\n\thttp.HandleFunc(\"/ws\", func(w http.ResponseWriter, r *http.Request) {\n\t\tconn, err := upgrader.Upgrade(w, r, nil)\n\t\tif err != nil {\n\t\t\tlog.Println(\"Upgrade error:\", err)\n\t\t\treturn\n\t\t}\n\t\tdefer conn.Close()\n\n\t\tfor {\n\t\t\tmessageType, p, err := conn.ReadMessage()\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"Read error:\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err := conn.WriteMessage(messageType, p); err != nil {\n\t\t\t\tlog.Println(\"Write error:\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// (optional) return buffer to the pool\n\t\t\tconn.BufferPool().PutBuffer(p)\n\t\t}\n\t})\n\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n### Client Example\n\nHere's how to create a WebSocket client:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"github.com/simonfxr/wszero\"\n\t\"log\"\n)\n\nfunc main() {\n\tdialer := wszero.DefaultDialer\n\n\tconn, _, err := dialer.DialContext(context.Background(), \"ws://localhost:8080/ws\", nil)\n\tif err != nil {\n\t\tlog.Fatal(\"Dial error:\", err)\n\t}\n\tdefer conn.Close()\n\n\terr = conn.WriteMessageString(wszero.TextMessage, \"Hello, WebSocket!\")\n\tif err != nil {\n\t\tlog.Fatal(\"Write error:\", err)\n\t}\n\n\t_, message, err := conn.ReadMessage()\n\tif err != nil {\n\t\tlog.Fatal(\"Read error:\", err)\n\t}\n\n\tlog.Printf(\"Received: %s\", message)\n}\n```\n\n## Documentation\n\nFor detailed documentation, please refer to the [GoDoc](https://pkg.go.dev/github.com/simonfxr/wszero) page.\n\n## Autobahn Testsuite\n\nThe implementation passes all tests in the [Autobahn Testsuite](https://github.com/crossbario/autobahn-testsuite) except those that are related to the explicitly missing features listed above (UTF-8 validation of text messages and message compression).\n\n## Benchmarks comparisons with other implementations\n\nBenchmarks results on an AMD Ryzen 9 7950X using go 1.22.4.\n\n### WriteMessage benchmarks\n\n```\nBenchmarkWriteMessage/wszero[msgsz=2]-12              797.5 ns/op         2.51 MB/s           0 B/op     0 allocs/op\nBenchmarkWriteMessage/websocket[msgsz=2]-12            1403 ns/op         1.43 MB/s          76 B/op     3 allocs/op\nBenchmarkWriteMessage/gobwas[msgsz=2]-12               2017 ns/op         0.99 MB/s          40 B/op     3 allocs/op\nBenchmarkWriteMessage/nhooyr[msgsz=2]-12               1454 ns/op         1.38 MB/s           0 B/op     0 allocs/op\n\nBenchmarkWriteMessage/wszero[msgsz=128]-12             1069 ns/op       119.72 MB/s           0 B/op     0 allocs/op\nBenchmarkWriteMessage/websocket[msgsz=128]-12          1421 ns/op        90.08 MB/s          76 B/op     3 allocs/op\nBenchmarkWriteMessage/gobwas[msgsz=128]-12             1931 ns/op        66.30 MB/s          40 B/op     2 allocs/op\nBenchmarkWriteMessage/nhooyr[msgsz=128]-12             1577 ns/op        81.16 MB/s           0 B/op     0 allocs/op\n\nBenchmarkWriteMessage/wszero[msgsz=32768]-12           2281 ns/op      14365.28 MB/s          0 B/op     0 allocs/op\nBenchmarkWriteMessage/websocket[msgsz=32768]-12       11990 ns/op       2732.87 MB/s        104 B/op    10 allocs/op\nBenchmarkWriteMessage/gobwas[msgsz=32768]-12           3987 ns/op       8218.34 MB/s         40 B/op     2 allocs/op\nBenchmarkWriteMessage/nhooyr[msgsz=32768]-12           8418 ns/op       3892.80 MB/s          0 B/op     0 allocs/op\n\nBenchmarkWriteMessage/wszero[msgsz=262144]-12         14829 ns/op      17678.03 MB/s          0 B/op     0 allocs/op\nBenchmarkWriteMessage/websocket[msgsz=262144]-12     114598 ns/op       2287.51 MB/s        328 B/op    66 allocs/op\nBenchmarkWriteMessage/gobwas[msgsz=262144]-12         57441 ns/op       4563.70 MB/s     262186 B/op     3 allocs/op\nBenchmarkWriteMessage/nhooyr[msgsz=262144]-12         75932 ns/op       3452.36 MB/           0 B/op     0 allocs/op\n```\n\n### ReadMessage benchmarks\n\n```\nBenchmarkReadMessage/client/wszero[msgsz=2]-12                        19.99 ns/op     200.10 MB/s         0 B/op      0 allocs/op\nBenchmarkReadMessage/client/websocket[msgsz=2]-12                     123.2 ns/op      32.47 MB/s       520 B/op      2 allocs/op\nBenchmarkReadMessage/client/gobwas[msgsz=2]-12                        657.6 ns/op       6.08 MB/s       720 B/op      3 allocs/op\nBenchmarkReadMessage/client/nhooyr[msgsz=2]-12                         1124 ns/op       3.56 MB/s       512 B/op      1 allocs/op\n\nBenchmarkReadMessage/client/wszero[msgsz=128]-12                      42.45 ns/op    3109.90 MB/s         0 B/op      0 allocs/op\nBenchmarkReadMessage/client/websocket[msgsz=128]-12                   166.7 ns/op     791.96 MB/s       520 B/op      2 allocs/op\nBenchmarkReadMessage/client/gobwas[msgsz=128]-12                      861.3 ns/op     153.25 MB/s       720 B/op      3 allocs/op\nBenchmarkReadMessage/client/nhooyr[msgsz=128]-12                       1188 ns/op     111.09 MB/s       512 B/op      1 allocs/op\n\nBenchmarkReadMessage/client/wszero[msgsz=32768]-12                   3008 ns/op     10894.07 MB/s         0 B/op      0 allocs/op\nBenchmarkReadMessage/client/websocket[msgsz=32768]-12               28812 ns/op      1137.43 MB/s    153866 B/op     15 allocs/op\nBenchmarkReadMessage/client/gobwas[msgsz=32768]-12                  26988 ns/op      1214.30 MB/s    154066 B/op     16 allocs/op\nBenchmarkReadMessage/client/nhooyr[msgsz=32768]-12                  47741 ns/op       686.46 MB/s    153860 B/op     14 allocs/op\n\n\nBenchmarkReadMessage/server-randmask/wszero[msgsz=2]-12               22.09 ns/op    362.15 MB/s         0 B/op      0 allocs/op\nBenchmarkReadMessage/server-randmask/websocket[msgsz=2]-12           137.9 ns/op      58.03 MB/s       520 B/op      2 allocs/op\nBenchmarkReadMessage/server-randmask/gobwas[msgsz=2]-12              860.7 ns/op       9.29 MB/s       752 B/op      4 allocs/op\nBenchmarkReadMessage/server-randmask/nhooyr[msgsz=2]-12               1071 ns/op       7.47 MB/s       512 B/op      1 allocs/op\n\nBenchmarkReadMessage/server-randmask/wszero[msgsz=128]-12             44.20 ns/op   3077.26 MB/s         0 B/op      0 allocs/op\nBenchmarkReadMessage/server-randmask/websocket[msgsz=128]-12         179.4 ns/op     757.95 MB/s       520 B/op      2 allocs/op\nBenchmarkReadMessage/server-randmask/gobwas[msgsz=128]-12            895.6 ns/op     151.86 MB/s       752 B/op      4 allocs/op\nBenchmarkReadMessage/server-randmask/nhooyr[msgsz=128]-12             1150 ns/op     118.28 MB/s       512 B/op      1 allocs/op\n\nBenchmarkReadMessage/server-randmask/wszero[msgsz=32768]-12         2931 ns/op     11182.41 MB/s        0 B/op      0 allocs/op\nBenchmarkReadMessage/server-randmask/websocket[msgsz=32768]-12     30984 ns/op      1057.83 MB/s   153866 B/op     15 allocs/op\nBenchmarkReadMessage/server-randmask/gobwas[msgsz=32768]-12        29046 ns/op      1128.42 MB/s   154098 B/op     17 allocs/op\nBenchmarkReadMessage/server-randmask/nhooyr[msgsz=32768]-12        49740 ns/op       658.95 MB/s   153860 B/op     14 allocs/op\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n# Similar projects\n\nHere is a selection of some existing similar projects\n\n- [gorilla/websocket](https://github.com/gorilla/websocket)\n- [gobwas/ws](https://github.com/gobwas/ws)\n- [nhooyr/websocket](https://github.com/nhooyr/websocket)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonfxr%2Fwszero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonfxr%2Fwszero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonfxr%2Fwszero/lists"}