Live reload for Go apps
open sourceGPL-3.0self-hostablefree
Air is a live-reloading command-line tool for developing Go applications: run air in the project root and it rebuilds and restarts the app whenever a watched file changes. A .air.toml file (air init writes one) or flags set the build command, the binary and its arguments, what to watch and exclude, .env files to load and per-OS overrides. Watch rules run a command such as templ generate or an asset build instead of a rebuild, and an optional proxy reloads the browser after each rebuild. It has an official Docker image, and it's for development, not hot deploys in production.
Ways to install
Package managers
Problems it solves
- restart my Go web server every time I save instead of ctrl-c and go run again
- live reload for a Gin, Echo or Fiber API while I develop it
- rebuild my Go binary and rerun it with the same arguments on each change
- refresh the browser by itself after my Go web app rebuilds
- run templ generate or sqlc when template files change, then rebuild the Go app
- hot reload a Go app running in a Docker container with my code mounted as a volume
- load .env files before building and running my Go service in development
- restart a Go program under the Delve debugger whenever the code changes
- exclude vendor, tmp and node_modules from my Go file watcher
Features
- .air.toml config, written by air init, or flags for every setting
- custom build command, entrypoint and binary arguments
- include and exclude by directory, extension, file and regex
- watches directories created after it starts
- watch rules that run a command instead of rebuilding
- proxy that reloads the browser after a successful rebuild
- .env file loading before build and run
- per-OS build overrides for Windows, macOS and Linux
- pre and post build commands
- colourful log output
View 1 more
- official Docker image (cosmtrek/air)
Limitations
- Doesn't hot-deploy in production: it's a live-reload tool for development only3
- Browser reload needs a </body> tag: its proxy serves pages without one unchanged3
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what Air does.