← 返回命令列表

Linux command

air 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start live reload

air

Initialize a default configuration

air init

Run with arguments

air -- [--port] [8080]

Use a custom configuration

air -c [path/to/.air.toml]

Specify custom build

air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api"

Show help

air -h

说明

Air is a live-reloading command line utility designed for Go application development. It watches your source files for changes and automatically rebuilds and restarts your application, eliminating the need to manually stop, rebuild, and restart during development. Run air in your project root directory and it monitors file changes based on configured extensions and directories. When changes are detected, Air rebuilds the application and restarts the binary. Configuration is managed through a .air.toml file that controls watched directories, excluded paths, file extensions, build commands, and environment variables. Air can load environment variables from .env files before building and running. The tool is intended for development workflows only and is not designed for production hot-deploy scenarios.

参数

init
Generate a default .air.toml configuration file in the current directory.
-c _FILE_
Specify a custom configuration file path.
--build.cmd _COMMAND_
Set the build command directly from command line.
--build.bin _PATH_
Set the path to the built binary.
--build.entrypoint _PATH_
Set the entrypoint for the binary.
--build.exclude_dir _DIRS_
Comma-separated list of directories to exclude from watching.
--build.include_ext _EXTS_
Comma-separated list of file extensions to watch (default: go,tpl,tmpl,html).
--build.delay _MS_
Delay in milliseconds before rebuilding after a change (default: 1000).
-d
Enable debug mode with verbose output.
--
Separator to pass remaining arguments to the built binary.

FAQ

What is the air command used for?

Air is a live-reloading command line utility designed for Go application development. It watches your source files for changes and automatically rebuilds and restarts your application, eliminating the need to manually stop, rebuild, and restart during development. Run air in your project root directory and it monitors file changes based on configured extensions and directories. When changes are detected, Air rebuilds the application and restarts the binary. Configuration is managed through a .air.toml file that controls watched directories, excluded paths, file extensions, build commands, and environment variables. Air can load environment variables from .env files before building and running. The tool is intended for development workflows only and is not designed for production hot-deploy scenarios.

How do I run a basic air example?

Run `air` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does init do in air?

Generate a default .air.toml configuration file in the current directory.