This project is an introduction to web-sockets using Go lang without using any framework. It uses the standard packages and simulates an orderbook.
- Repo setup
git clone https://github.com/IAmRiteshKoushik/go.sock-server
cd go.sock-server
go mod tidy
- Open two browsers side by side -> inspect element -> go to
console
- Type the following in both console:
let socket = new WebSocket("ws://localhost:3000/orderbook")
socket.onmessage = (event) => { console.log("Order received: ", event.data); }
You should see a stream of messages being sent to both instances of your browser console at a one second interval.