A minimal demonstration of Server-Sent Events (SSE) using Go and vanilla JavaScript. The server simulates live stock ticker updates for AAPL, GOOG, MSFT, AMZN, and TSLA, streaming them to a browser-based dashboard in real time.
- Go 1.25+
- A modern web browser
No external dependencies — the project uses only the Go standard library.
go run server.goOnce the server is running, open your browser and navigate to:
http://localhost:8080/
The dashboard connects automatically and starts displaying live stock price updates every second.
.
├── go.mod # Go module definition (zero external deps)
├── server.go # Go server with SSE broker and HTTP handlers
└── static/
└── index.html # Self-contained frontend dashboard
- Broker — A pub/sub fan-out broker manages connected SSE clients using Go channels.
- Ticker — A goroutine fires every second, picks a random stock symbol, generates a random price, and publishes a
stock-updateevent. - SSE Endpoint (
/events) — Streams events to each connected client using thetext/event-streamcontent type. - Dashboard (
/) — Uses the nativeEventSourceAPI to receive events and render a live-updating price table with an event log.
| Endpoint | Description |
|---|---|
GET / |
Serves the dashboard UI |
GET /events |
SSE stream of stock price updates |