Live-Reload for Go Services (Air)
By Engineering Team•October 11, 2026•2 min read
Air watches a Go project’s source files and rebuilds/restarts the running binary automatically on save, so you’re not stopping and re-running go run by hand after every change.
1. Install Air
go install github.com/air-verse/air@latest
Verify it’s on your PATH:
air -v
If this doesn’t resolve, confirm $(go env GOPATH)/bin is on your shell’s PATH — see Installing Go (macOS) for that step.
2. Initialize a Config
From the service’s own src/ directory (where its go.mod/go.work lives):
air init
This creates an .air.toml file.
3. Point It at the Service’s Entry Point
Open .air.toml and adjust the [build] section for the service you’re working on:
[build]
cmd = "go build -o ./tmp/main ./cmd/server" # point at this service's actual main package
bin = "./tmp/main"
include_ext = ["go", "tpl", "tmpl", "html", "yml"]
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
cmdmust point at the service’s real entry-point package — check that service’s own layout before assuming a path.exclude_dirshould always list the service’s generated-code output directories (e.g. anything ago:generatestep writes into) so Air doesn’t restart itself in a loop reacting to its own generated files.- If the service runs a code-generation step before every build (e.g.
gqlgen generatefor a GraphQL schema, or ago:generatedirective), add it as apre_cmdso regenerated code is always in sync before the rebuild:
Only add this if the service you’re working on actually has a code-generation step — most services in this monorepo don’t need one.pre_cmd = "go run github.com/99designs/gqlgen generate"
4. Run It
air
Air rebuilds and restarts the binary every time a watched file changes, printing compiler errors directly to the terminal instead of silently failing.