Air — Live Reload for Go Applications
Air provides live reload for Go development. It watches your source files, automatically rebuilds on changes, and restarts the binary — giving you a hot-reload experience similar to nodemon for Node.js or Flask debug mode for Python.
What it is
Air is a live-reload utility for Go applications. It monitors your project directory with fsnotify, and every time a .go file changes it rebuilds the project and restarts the binary automatically. This brings the instant feedback loop common in JavaScript (nodemon) and Python (Flask debug mode) to Go development.
Air is aimed at Go backend developers who want faster iteration cycles during local development. It supports custom build commands, file exclusion patterns, colored log output, and proxy mode for web frameworks.
How it saves time or tokens
Without Air, every code change requires manually stopping the server, running go build, and restarting. Air collapses this into a single save action. It handles debouncing (multiple rapid saves trigger only one rebuild), displays build errors inline without crashing, and forwards signals like SIGINT so graceful shutdown works correctly.
For teams using AI coding assistants that write and edit Go files, Air keeps the running server always in sync with the latest code without manual intervention.
How to use
- Install Air:
go install github.com/air-verse/air@latest
- Initialize the config file in your project root:
air init
This creates .air.toml with sensible defaults.
- Start watching:
air
Air now rebuilds and restarts on every file change.
Example
Minimal .air.toml configuration:
root = '.'
tmp_dir = 'tmp'
[build]
cmd = 'go build -o ./tmp/main .'
bin = './tmp/main'
watch = ['.']
exclude_dir = ['assets', 'tmp', 'vendor', 'node_modules']
include_ext = ['go', 'tpl', 'tmpl', 'html']
delay = 1000 # ms debounce
[log]
color = true
Or run without any config file:
air --build.cmd 'go build -o ./tmp/main .' --build.bin './tmp/main'
Related on TokRepo
- Automation Tools -- Developer workflow automation and productivity tools
- DevOps Tools -- Build, deploy, and infrastructure tooling
Common pitfalls
- Air watches the current directory by default. If your main package is in a subdirectory, set
rootin.air.tomlor run Air from that directory. - On macOS, fsnotify may hit the default file descriptor limit with large projects. Increase it with
ulimit -n 10240if Air misses changes. - Air does not run tests automatically. Pair it with a separate test watcher if you want test-on-save behavior.
Frequently Asked Questions
Air serves the same purpose as nodemon but for Go. It watches source files, rebuilds on change, and restarts the binary. The key difference is Air runs a full Go compilation step, while nodemon simply restarts the Node.js process.
Yes. Air runs whatever build command you configure, typically 'go build', which respects your go.mod and module dependencies. No special configuration is needed for Go modules.
Yes. Set the include_ext option in .air.toml to list additional file extensions. For example, adding 'html' and 'tmpl' triggers a rebuild when template files change.
Air includes a proxy mode that can forward requests to your application. This is useful for web frameworks where you want Air to manage both the rebuild cycle and request proxying during development.
Use the exclude_dir setting in .air.toml. Common exclusions include vendor, node_modules, tmp, and assets directories to avoid unnecessary rebuilds.
Citations (3)
- Air GitHub Repository— Air provides live reload for Go development with fsnotify-based file watching
- Go Documentation— Go install command for installing Go binaries from module sources
- fsnotify GitHub— fsnotify provides cross-platform filesystem notifications for Go
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.