Live Reload in 20 Lines of Go

How gax serve injects __ping and reloads browser without websocket.

# golang # live-reload # tutorial

Live Reload in 20 Lines of Go

16 Aug 2026

No websocket. No complexity.

In render.go:


if ctx["__live"] == true {
  liveScript := ``
  content = strings.Replace(content, "", liveScript+"", 1)
}

Poll every 1s. If mtime changed, reload. 20 lines. Works everywhere.


GAX GO Static Site Generator Built with GAX