The Pain of Manual Rebuilds

Every Go developer knows this cycle: write code, press Ctrl+C to stop the running app, run go build or go run, then restart. Repeat for every single change. It’s tedious, breaks your flow, and eats away precious development time.

What if I told you there’s a better way?

Enter Air

Air is a live reload tool for Go applications. It watches your source files, automatically rebuilds your binary when changes are detected, and restarts your application — all without you lifting a finger.

Why Air?

  • Zero manual intervention — Save a file, air rebuilds and restarts
  • Clean output — ANSI-colored output that doesn’t clutter your terminal
  • Configurable — Fine-tune exclude patterns, build commands, and more
  • Cross-platform — Works on Linux, macOS, and Windows

Installation

# Install via go install
go install github.com/air-verse/air@latest

# Or use your preferred package manager
# Homebrew
brew install air

# Binary release
curl -sSfL https://raw.githubusercontent.com/air-verse/air/master/install.sh | sh

Quick Start

# Initialize air config in your project
air init

# Run your app with hot reload
air

This creates a .air.toml config file. Here’s a typical configuration:

root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
  args_bin = []
  bin = "./tmp/main"
  cmd = "go build -o ./tmp/main ."
  delay = 1000
  exclude_dir = ["assets", "tmp", "vendor", "testdata"]
  exclude_file = []
  exclude_regex = ["_test.go"]
  exclude_unchanged = false
  follow_symlinks = false
  full_bin = ""
  include_dir = []
  include_ext = ["go", "tpl", "tmpl", "html"]
  include_file = []
  kill_delay = "0s"
  log = "build-errors.log"
  poll = false
  poll_interval = 0
  rerun = false
  rerun_delay = 500
  send_interrupt = false
  stop_on_error = false

[color]
  app = ""
  build = "yellow"
  main = "magenta"
  runner = "green"
  watcher = "cyan"

[log]
  main_only = false
  time = false

[misc]
  clean_on_exit = false

[screen]
  clear_on_rebuild = false
  keep_scroll = true

Air vs Traditional Workflow

Task Without Air With Air
Change code Ctrl+C → rebuild → run Save file
Wait time Manual every time Automatic
Focus Broken constantly Flow state maintained

Use Cases

Air shines in scenarios where rapid iteration matters:

  • API development — Instantly see endpoint changes
  • Web applications — Frontend + backend combined projects
  • CLI tools — Test command-line arguments quickly
  • Learning — Perfect for Go tutorials and experiments

Pro Tips

  1. Exclude directories — Add node_modules, vendor, and other dirs to exclude_dir to avoid unnecessary rebuilds.

  2. Custom build flags — Use -ldflags for debug info during development:

    cmd = "go build -ldflags '-s -w' -o ./tmp/main ."
    
  3. Hot module complement — For frontend-heavy projects, combine Air with a frontend bundler (Vite, esbuild) for full-stack hot reload.

The Bottom Line

Air transforms your Go development experience from “stop, build, run, repeat” to “just code.” It’s lightweight, simple to set up, and gets out of your way when you don’t need it.

If you’re still manually rebuilding your Go apps, give air a try. Your fingers — and your sanity — will thank you.


References: