Socket.IO for Go
github.com/malcolmston/socketio
Bidirectional, low-latency, event-based communication.
GitHubports socketio/socket.io
A dependency-free Socket.IO server (and Go client) speaking the real wire protocol — Engine.IO v4 (polling + WebSocket + upgrade) and Socket.IO v5 (namespaces, rooms, acks, binary). The WebSocket layer is RFC 6455 from scratch. Interoperates with socket.io-client@4.
Install
shell
$ go get github.com/malcolmston/socketioQuick start
main.go
io := socketio.New()
io.OnConnection(func(s *socketio.Socket) {
s.Join("general")
s.On("chat", func(args []any) []any {
io.To("general").Emit("chat", args...)
return nil
})
})
http.Handle(socketio.DefaultPath, io)Features
- Both transports: HTTP long-polling and WebSocket, with the polling→WS upgrade
- Namespaces, rooms, broadcasting, acknowledgements (both directions)
- Per-socket data store — the equivalent of
socket.data - Connection middleware (
io.Use), binary attachments - Pluggable
Adapter+ a RedisBroadcasterfor multi-node scale-out - Mounts alongside Express via
io.Handler(app) - Ships a Go client with reconnection and
EmitWithAck