What is Air and why is it needed?
\n\nAir is a powerful utility for Go developers that provides live reload (hot reload) for applications. If you have ever written web applications in Go, you know how tedious it is to manually stop the server (Ctrl+C), recompile the project (go build), and start it again each time. Air automates this process: it monitors changes in your project's source code and automatically rebuilds and restarts the application whenever a file is saved.
\n\nAir was created by the Cosmos team (formerly known as Tendermint) and is written in Go itself. It is not a library in the classical sense (you do not import it into your code), but rather a command-line tool that runs alongside your application.
\n\nWhy is Air needed?
\n- \n
- Accelerates development: saves minutes spent on manual recompilation. \n
- Convenience: just save a file — and the server restarts automatically. \n
- Supports any Go project: works with web servers, CLI utilities, Telegram bots, and any other applications. \n
- Flexible configuration: you can configure folder ignoring, delays, additional commands, and much more. \n
Air is especially useful when developing web applications on frameworks like Gin, Echo, Fiber, or the standard net/http, where every edit requires a server restart.
\n\nInstalling Air
\n\nAir can be installed in several ways. Choose the one most suitable for your system.
\n\nMethod 1: Installation via go install (recommended)
\nThe simplest way is to use the standard Go package manager. Make sure you have Go version 1.16 or higher installed.
\ngo install github.com/air-verse/air@latest\nAfter this, the air binary will be placed in the $GOPATH/bin directory (usually ~/go/bin). Make sure this directory is added to the PATH environment variable.
Method 2: Installation via Homebrew (macOS / Linux)
\nIf you are using macOS or Linux with Homebrew, installation is trivial:
\nbrew install air\n\nMethod 3: Installation via script (Linux / macOS / WSL)
\nYou can use the installation script:
\ncurl -sSfL https://raw.githubusercontent.com/air-verse/air/master/install.sh | sh -s\n\nMethod 4: Installation via Docker
\nFor those who prefer Docker:
\ndocker run -it --rm -v "$PWD":/app -w /app cosmtrek/air\n\nVerifying installation
\nAfter installation, verify that Air works:
\nair -v\nYou should see the utility version, for example: v1.52.3
Quick start with a code example
\n\nLet's create a simple web application in Go and set up live reload for it using Air.
\n\nStep 1: Create a new project
\nmkdir my-air-app\ncd my-air-app\ngo mod init my-air-app\n\nStep 2: Write a simple HTTP server
\nCreate a file main.go:
package main\n\nimport (\n "fmt"\n "net/http"\n)\n\nfunc main() {\n http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "Hello, Air! Current time: %s", time.Now().Format("15:04:05"))\n })\n\n fmt.Println("Server started on http://localhost:8080")\n http.ListenAndServe(":8080", nil)\n}\n\nStep 3: Initialize Air configuration
\nair init\nThis command creates a .air.toml file in the project root with default settings. You can edit it later to suit your needs.
Step 4: Run Air
\nair\nYou will see output, by