Skip to content

Air

Keeps Golang project up-and-running with hot-loading.

Usage

First, download and initiate Air package:

bash
go install github.com/air-verse/air@latest
air init

Make neccesary changes to the generated configuration file .air.toml with your needs, then run air with:

bash
air

Windows/Cross-OS handling

To co-work with Windows operating systems, the simplest approach is to use a specific configuration file duplicated from .air.toml with minor amendments to handle path differences.

bash
cp .air.toml .air.windows.toml

Change executable file path and build command configs under build group from Linux/macOS style to Windows, for example from:

toml
[build]
  entrypoint = "tmp/main"
  cmd = "go build -o ./tmp/main ./src/cmd"

To:

toml
[build]
  entrypoint = "tmp\\main.exe"
  cmd = "go build -o ./tmp/main.exe ./src/cmd"

Now you could get air work with specified config file for Windows OS, while the Linux/macOS work spaces remains working.

bash
air -c .air.windows.toml

References