Air automatically rebuilds and restarts your server when you change code:
# Install Air (one-time setup)
go install github.com/air-verse/air@latest
# Run with auto-reload
make dev-air
# OR
airBenefits:
- ✅ No manual rebuilds needed
- ✅ Automatic restart on code changes
- ✅ Faster development workflow
If you prefer manual control or don't want to install Air:
# Run directly (rebuilds on each run)
make dev
# OR
go run cmd/server/main.goNote: You'll need to manually stop and restart when you change code.
For production-like testing:
# Build once
make build
# Run the binary
make run
# OR
./bin/serverNote: You need to rebuild (make build) every time you change code.
- When using
make dev-airorair- Air handles everything automatically - When using
make devorgo run- Go rebuilds automatically on each run
- When using
make build+make run- You must rebuild after code changes - When deploying to production - Always rebuild for production
# Terminal 1: Run server with auto-reload
make dev-air
# Terminal 2: Run tests
make test
# Terminal 3: Run linter
make lint# Simple run (auto-rebuilds each time)
make dev# Build optimized binary
make build
# Test the binary
make rungo install github.com/air-verse/air@latest- Check
.air.tomlconfiguration - Ensure files are in
include_extlist - Check
exclude_dirdoesn't exclude your files
- Check
build-errors.logfile (created by Air) - Run
go build ./cmd/servermanually to see errors
Air watches for changes in:
.gofiles- Template files (
.tpl,.tmpl,.html)
Air ignores:
bin/,tmp/,vendor/,testdata/directories*_test.gofiles- Files matching exclude patterns
- Use Air for development - Fastest iteration cycle
- Use
make devfor quick tests - No setup needed - Use
make buildfor production - Optimized binary