ScriptsApr 13, 2026·3 min read

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.

TL;DR
Air watches your Go files and auto-rebuilds plus restarts the binary on every save, like nodemon for Go.
§01

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.

§02

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.

§03

How to use

  1. Install Air:
go install github.com/air-verse/air@latest
  1. Initialize the config file in your project root:
air init

This creates .air.toml with sensible defaults.

  1. Start watching:
air

Air now rebuilds and restarts on every file change.

§04

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'
§05

Related on TokRepo

§06

Common pitfalls

  • Air watches the current directory by default. If your main package is in a subdirectory, set root in .air.toml or run Air from that directory.
  • On macOS, fsnotify may hit the default file descriptor limit with large projects. Increase it with ulimit -n 10240 if 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

How does Air compare to nodemon for Node.js?+

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.

Does Air work with Go modules?+

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.

Can Air watch non-Go files like templates or HTML?+

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.

Does Air support proxy mode for web frameworks?+

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.

How do I exclude directories from watching?+

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

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets