Server-Sent Events (SSE) in Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Go Server-Sent Events Example


Server-Sent Events allow real-time one-way communications from the server to client over HTTP. You can send updates and notifications on-the-fly this way.

Server-sent events are implemented on top of HTTP while websockets are not.

Installing and Running

$ go get $SRCPATH
$ go run $GOPATH/src/$SRCPATH/server_sent_events.go

Then, either visit with a modern web browser or

$ curl


  • There's a strange feature where connections take more than 10 seconds when visiting concurrently from a browser. This is probably some caching behavior, but I'm not sure. Concurrent connections from curl and Javascript EventSource have no delay.
  • This implementation does not utilize Event IDs as per the specification:
  • Why the long project name? To prevent confusion
  • Thanks to cronos from for reviewing my code

Feel free to send pull requests or leave comments.