fix typo (#595)
* chore: fix typo in code * chore: fix tool names or registered trademarks Docker Codecov Bash Zsh Also HTML is an acronym, so it has to be in uppercase * documentation: fix Markdown fenced block identifier some were using sh, zsh, most where using bash, some were missing I updated to use shell everywhere
This commit is contained in:
+21
-17
@@ -1,4 +1,4 @@
|
|||||||
# Air [](https://github.com/cosmtrek/air/actions?query=workflow%3AGo+branch%3Amaster) [](https://www.codacy.com/gh/cosmtrek/air/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cosmtrek/air&utm_campaign=Badge_Grade) [](https://goreportcard.com/report/github.com/cosmtrek/air) [](https://codecov.io/gh/cosmtrek/air)
|
# Air [](https://github.com/cosmtrek/air/actions?query=workflow%3AGo+branch%3Amaster) [](https://www.codacy.com/gh/cosmtrek/air/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cosmtrek/air&utm_campaign=Badge_Grade) [](https://goreportcard.com/report/github.com/cosmtrek/air) [](https://codecov.io/gh/cosmtrek/air)
|
||||||
|
|
||||||
:cloud: 热重载 Go 应用的工具
|
:cloud: 热重载 Go 应用的工具
|
||||||
|
|
||||||
@@ -28,17 +28,21 @@ Air 是为 Go 应用开发设计的另外一个热重载的命令行工具。只
|
|||||||
|
|
||||||
如果你只是想配置构建命令和运行命令,您可以直接使用以下命令,而无需配置文件:
|
如果你只是想配置构建命令和运行命令,您可以直接使用以下命令,而无需配置文件:
|
||||||
|
|
||||||
`air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api"`
|
```shell
|
||||||
|
air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api"
|
||||||
|
```
|
||||||
|
|
||||||
对于以列表形式输入的参数,使用逗号来分隔项目:
|
对于以列表形式输入的参数,使用逗号来分隔项目:
|
||||||
|
|
||||||
`air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api" --build.exclude_dir "templates,build"`
|
```shell
|
||||||
|
air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api" --build.exclude_dir "templates,build"
|
||||||
|
```
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
### 推荐使用 install.sh
|
### 推荐使用 install.sh
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# binary 文件会是在 $(go env GOPATH)/bin/air
|
# binary 文件会是在 $(go env GOPATH)/bin/air
|
||||||
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
||||||
|
|
||||||
@@ -54,7 +58,7 @@ P.S. 非常感谢 mattn 的 [PR](https://github.com/cosmtrek/air/pull/1),使
|
|||||||
|
|
||||||
使用 Go 的版本为 1.22 或更高:
|
使用 Go 的版本为 1.22 或更高:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
go install github.com/cosmtrek/air@latest
|
go install github.com/cosmtrek/air@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -62,7 +66,7 @@ go install github.com/cosmtrek/air@latest
|
|||||||
|
|
||||||
请拉取这个 Docker 镜像 [cosmtrek/air](https://hub.docker.com/r/cosmtrek/air).
|
请拉取这个 Docker 镜像 [cosmtrek/air](https://hub.docker.com/r/cosmtrek/air).
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker run -it --rm \
|
docker run -it --rm \
|
||||||
-w "<PROJECT>" \
|
-w "<PROJECT>" \
|
||||||
-e "air_wd=<PROJECT>" \
|
-e "air_wd=<PROJECT>" \
|
||||||
@@ -74,7 +78,7 @@ docker run -it --rm \
|
|||||||
|
|
||||||
例如,我的项目之一是在 Docker 上运行的:
|
例如,我的项目之一是在 Docker 上运行的:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker run -it --rm \
|
docker run -it --rm \
|
||||||
-w "/go/src/github.com/cosmtrek/hub" \
|
-w "/go/src/github.com/cosmtrek/hub" \
|
||||||
-v $(pwd):/go/src/github.com/cosmtrek/hub \
|
-v $(pwd):/go/src/github.com/cosmtrek/hub \
|
||||||
@@ -88,26 +92,26 @@ docker run -it --rm \
|
|||||||
|
|
||||||
首先,进入你的项目文件夹
|
首先,进入你的项目文件夹
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
cd /path/to/your_project
|
cd /path/to/your_project
|
||||||
```
|
```
|
||||||
|
|
||||||
最简单的方法是执行
|
最简单的方法是执行
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# 优先在当前路径查找 `.air.toml` 后缀的文件,如果没有找到,则使用默认的
|
# 优先在当前路径查找 `.air.toml` 后缀的文件,如果没有找到,则使用默认的
|
||||||
air -c .air.toml
|
air -c .air.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
您可以运行以下命令初始化,把默认配置添加到当前路径下的`.air.toml` 文件。
|
您可以运行以下命令初始化,把默认配置添加到当前路径下的`.air.toml` 文件。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air init
|
air init
|
||||||
```
|
```
|
||||||
|
|
||||||
在这之后,你只需执行 `air` 命令,无需添加额外的变量,它就能使用 `.air.toml` 文件中的配置了。
|
在这之后,你只需执行 `air` 命令,无需添加额外的变量,它就能使用 `.air.toml` 文件中的配置了。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air
|
air
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -117,7 +121,7 @@ air
|
|||||||
|
|
||||||
您可以通过把变量添加在 air 命令之后来传递参数。
|
您可以通过把变量添加在 air 命令之后来传递参数。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# 会执行 ./tmp/main bench
|
# 会执行 ./tmp/main bench
|
||||||
air bench
|
air bench
|
||||||
|
|
||||||
@@ -127,7 +131,7 @@ air server --port 8080
|
|||||||
|
|
||||||
You can separate the arguments passed for the air command and the built binary with `--` argument.
|
You can separate the arguments passed for the air command and the built binary with `--` argument.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# 会运行 ./tmp/main -h
|
# 会运行 ./tmp/main -h
|
||||||
air -- -h
|
air -- -h
|
||||||
|
|
||||||
@@ -135,7 +139,7 @@ air -- -h
|
|||||||
air -c .air.toml -- -h
|
air -c .air.toml -- -h
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker-compose
|
### Docker Compose
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
@@ -161,7 +165,7 @@ services:
|
|||||||
|
|
||||||
### 遇到 "command not found: air" 或 "No such file or directory" 该怎么办?
|
### 遇到 "command not found: air" 或 "No such file or directory" 该怎么办?
|
||||||
|
|
||||||
```zsh
|
```shell
|
||||||
export GOPATH=$HOME/xxxxx
|
export GOPATH=$HOME/xxxxx
|
||||||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||||
export PATH=$PATH:$(go env GOPATH)/bin <---- 请确认这行在您的配置信息中!!!
|
export PATH=$PATH:$(go env GOPATH)/bin <---- 请确认这行在您的配置信息中!!!
|
||||||
@@ -171,7 +175,7 @@ export PATH=$PATH:$(go env GOPATH)/bin <---- 请确认这行在您的配置信
|
|||||||
|
|
||||||
请注意:这需要 Go 1.16+ ,因为我使用 `go mod` 来管理依赖。
|
请注意:这需要 Go 1.16+ ,因为我使用 `go mod` 来管理依赖。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# 1. 首先复刻(fork)这个项目
|
# 1. 首先复刻(fork)这个项目
|
||||||
|
|
||||||
# 2. 其次克隆(clone)它
|
# 2. 其次克隆(clone)它
|
||||||
@@ -191,7 +195,7 @@ make install
|
|||||||
|
|
||||||
### 发布新版本
|
### 发布新版本
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# 1. checkout 到 master 分支
|
# 1. checkout 到 master 分支
|
||||||
git checkout master
|
git checkout master
|
||||||
|
|
||||||
|
|||||||
+28
-24
@@ -1,6 +1,6 @@
|
|||||||
# :cloud: Air - Live reload for Go apps
|
# :cloud: Air - Live reload for Go apps
|
||||||
|
|
||||||
[](https://github.com/cosmtrek/air/actions?query=workflow%3AGo+branch%3Amaster) [](https://www.codacy.com/gh/cosmtrek/air/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cosmtrek/air&utm_campaign=Badge_Grade) [](https://goreportcard.com/report/github.com/cosmtrek/air) [](https://codecov.io/gh/cosmtrek/air)
|
[](https://github.com/cosmtrek/air/actions?query=workflow%3AGo+branch%3Amaster) [](https://www.codacy.com/gh/cosmtrek/air/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cosmtrek/air&utm_campaign=Badge_Grade) [](https://goreportcard.com/report/github.com/cosmtrek/air) [](https://codecov.io/gh/cosmtrek/air)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -28,11 +28,15 @@ Air 是一個另類的自動重新編譯執行命令列工具,用於開發 Go
|
|||||||
|
|
||||||
如果你想設定建置命令和執行命令,你可以在不需要配置檔案的情況下如下使用命令:
|
如果你想設定建置命令和執行命令,你可以在不需要配置檔案的情況下如下使用命令:
|
||||||
|
|
||||||
`air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api"`
|
```shell
|
||||||
|
air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api"`
|
||||||
|
```
|
||||||
|
|
||||||
對於需要輸入列表的參數,可以使用逗號將項目分隔:
|
對於需要輸入列表的參數,可以使用逗號將項目分隔:
|
||||||
|
|
||||||
`air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api" --build.exclude_dir "templates,build"`
|
```shell
|
||||||
|
air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api" --build.exclude_dir "templates,build"
|
||||||
|
```
|
||||||
|
|
||||||
## 安裝
|
## 安裝
|
||||||
|
|
||||||
@@ -40,13 +44,13 @@ Air 是一個另類的自動重新編譯執行命令列工具,用於開發 Go
|
|||||||
|
|
||||||
需要使用 go 1.22 或更高版本:
|
需要使用 go 1.22 或更高版本:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
go install github.com/cosmtrek/air@latest
|
go install github.com/cosmtrek/air@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### 透過 install.sh
|
### 透過 install.sh
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# binary will be $(go env GOPATH)/bin/air
|
# binary will be $(go env GOPATH)/bin/air
|
||||||
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
||||||
|
|
||||||
@@ -58,7 +62,7 @@ air -v
|
|||||||
|
|
||||||
### 透過 [goblin.run](https://goblin.run)
|
### 透過 [goblin.run](https://goblin.run)
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
# binary will be /usr/local/bin/air
|
# binary will be /usr/local/bin/air
|
||||||
curl -sSfL https://goblin.run/github.com/cosmtrek/air | sh
|
curl -sSfL https://goblin.run/github.com/cosmtrek/air | sh
|
||||||
|
|
||||||
@@ -70,7 +74,7 @@ curl -sSfL https://goblin.run/github.com/cosmtrek/air | PREFIX=/tmp sh
|
|||||||
|
|
||||||
使用 go 1.18 或更高版本:
|
使用 go 1.18 或更高版本:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
go install github.com/cosmtrek/air@latest
|
go install github.com/cosmtrek/air@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -78,7 +82,7 @@ go install github.com/cosmtrek/air@latest
|
|||||||
|
|
||||||
請讀取 Docker 映像檔 [cosmtrek/air](https://hub.docker.com/r/cosmtrek/air).
|
請讀取 Docker 映像檔 [cosmtrek/air](https://hub.docker.com/r/cosmtrek/air).
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker/podman run -it --rm \
|
docker/podman run -it --rm \
|
||||||
-w "<PROJECT>" \
|
-w "<PROJECT>" \
|
||||||
-e "air_wd=<PROJECT>" \
|
-e "air_wd=<PROJECT>" \
|
||||||
@@ -90,9 +94,9 @@ docker/podman run -it --rm \
|
|||||||
|
|
||||||
#### Docker/Podman .${SHELL}rc
|
#### Docker/Podman .${SHELL}rc
|
||||||
|
|
||||||
如果你想像常規應用程式一樣持續使用 air,你可以在你的 ${SHELL}rc (bash,zsh, etc...) 中創建一個函數。
|
如果你想像常規應用程式一樣持續使用 air,你可以在你的 ${SHELL}rc (Bash, Zsh, etc…) 中創建一個函數。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air() {
|
air() {
|
||||||
podman/docker run -it --rm \
|
podman/docker run -it --rm \
|
||||||
-w "$PWD" -v "$PWD":"$PWD" \
|
-w "$PWD" -v "$PWD":"$PWD" \
|
||||||
@@ -106,19 +110,19 @@ air() {
|
|||||||
<details>
|
<details>
|
||||||
<summary>For example</summary>
|
<summary>For example</summary>
|
||||||
|
|
||||||
我其中一個專案是在 docker 中運行
|
我其中一個專案是在 Docker 中運行
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker run -it --rm \
|
docker run -it --rm \
|
||||||
-w "/go/src/github.com/cosmtrek/hub" \
|
-w "/go/src/github.com/cosmtrek/hub" \
|
||||||
-v $(pwd):/go/src/github.com/cosmtrek/hub \
|
-v $(pwd):/go/src/github.com/cosmtrek/hub \
|
||||||
-p 9090:9090 \
|
-p 9090:9090 \
|
||||||
cosmtrek/air
|
cosmtrek/air
|
||||||
```
|
```
|
||||||
|
|
||||||
另一個例子
|
另一個例子
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
cd /go/src/github.com/cosmtrek/hub
|
cd /go/src/github.com/cosmtrek/hub
|
||||||
AIR_PORT=8080 air -c "config.toml"
|
AIR_PORT=8080 air -c "config.toml"
|
||||||
```
|
```
|
||||||
@@ -133,26 +137,26 @@ AIR_PORT=8080 air -c "config.toml"
|
|||||||
|
|
||||||
首先,進入你的專案目錄
|
首先,進入你的專案目錄
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
cd /path/to/your_project
|
cd /path/to/your_project
|
||||||
```
|
```
|
||||||
|
|
||||||
最簡單的使用方式是運行
|
最簡單的使用方式是運行
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# firstly find `.air.toml` in current directory, if not found, use defaults
|
# firstly find `.air.toml` in current directory, if not found, use defaults
|
||||||
air -c .air.toml
|
air -c .air.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
你可以用以下命令初始化 `.air.toml` 配置檔到當前目錄,並使用預設設置。
|
你可以用以下命令初始化 `.air.toml` 配置檔到當前目錄,並使用預設設置。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air init
|
air init
|
||||||
```
|
```
|
||||||
|
|
||||||
此後,你可以只運行 `air` 命令,而不需要額外的參數,它將使用 `.air.toml` 檔案作為配置。
|
此後,你可以只運行 `air` 命令,而不需要額外的參數,它將使用 `.air.toml` 檔案作為配置。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air
|
air
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -162,7 +166,7 @@ air
|
|||||||
|
|
||||||
你可以在 air 命令後添加參數來運行已構建的二進制檔。
|
你可以在 air 命令後添加參數來運行已構建的二進制檔。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Will run ./tmp/main bench
|
# Will run ./tmp/main bench
|
||||||
air bench
|
air bench
|
||||||
|
|
||||||
@@ -172,7 +176,7 @@ air server --port 8080
|
|||||||
|
|
||||||
你可以使用 `--` 參數來分隔傳遞給 air 命令和已建構的二進制檔的參數。
|
你可以使用 `--` 參數來分隔傳遞給 air 命令和已建構的二進制檔的參數。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Will run ./tmp/main -h
|
# Will run ./tmp/main -h
|
||||||
air -- -h
|
air -- -h
|
||||||
|
|
||||||
@@ -180,7 +184,7 @@ air -- -h
|
|||||||
air -c .air.toml -- -h
|
air -c .air.toml -- -h
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker-compose
|
### Docker Compose
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
@@ -241,7 +245,7 @@ services:
|
|||||||
|
|
||||||
### "找不到命令:air" 或者 "找不到檔案或目錄"
|
### "找不到命令:air" 或者 "找不到檔案或目錄"
|
||||||
|
|
||||||
```zsh
|
```shell
|
||||||
export GOPATH=$HOME/xxxxx
|
export GOPATH=$HOME/xxxxx
|
||||||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||||
export PATH=$PATH:$(go env GOPATH)/bin <---- Confirm this line in you profile!!!
|
export PATH=$PATH:$(go env GOPATH)/bin <---- Confirm this line in you profile!!!
|
||||||
@@ -255,7 +259,7 @@ export PATH=$PATH:$(go env GOPATH)/bin <---- Confirm this line in you profile!!!
|
|||||||
|
|
||||||
請注意,由於我使用 `go mod` 來管理依賴,所以需要 Go 1.16+。
|
請注意,由於我使用 `go mod` 來管理依賴,所以需要 Go 1.16+。
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Fork this project
|
# Fork this project
|
||||||
|
|
||||||
# Clone it
|
# Clone it
|
||||||
@@ -275,7 +279,7 @@ make install
|
|||||||
|
|
||||||
### 發佈版本
|
### 發佈版本
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Checkout to master
|
# Checkout to master
|
||||||
git checkout master
|
git checkout master
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# :cloud: Air - Live reload for Go apps
|
# :cloud: Air - Live reload for Go apps
|
||||||
|
|
||||||
[](https://github.com/cosmtrek/air/actions?query=workflow%3AGo+branch%3Amaster) [](https://www.codacy.com/gh/cosmtrek/air/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cosmtrek/air&utm_campaign=Badge_Grade) [](https://goreportcard.com/report/github.com/cosmtrek/air) [](https://codecov.io/gh/cosmtrek/air)
|
[](https://github.com/cosmtrek/air/actions?query=workflow%3AGo+branch%3Amaster) [](https://www.codacy.com/gh/cosmtrek/air/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cosmtrek/air&utm_campaign=Badge_Grade) [](https://goreportcard.com/report/github.com/cosmtrek/air) [](https://codecov.io/gh/cosmtrek/air)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -32,11 +32,15 @@ Support air config fields as arguments:
|
|||||||
|
|
||||||
If you want to config build command and run command, you can use like the following command without the config file:
|
If you want to config build command and run command, you can use like the following command without the config file:
|
||||||
|
|
||||||
`air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api"`
|
```shell
|
||||||
|
air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api"
|
||||||
|
```
|
||||||
|
|
||||||
Use a comma to separate items for arguments that take a list as input:
|
Use a comma to separate items for arguments that take a list as input:
|
||||||
|
|
||||||
`air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api" --build.exclude_dir "templates,build"`
|
```shell
|
||||||
|
air --build.cmd "go build -o bin/api cmd/run.go" --build.bin "./bin/api" --build.exclude_dir "templates,build"
|
||||||
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -44,13 +48,13 @@ Use a comma to separate items for arguments that take a list as input:
|
|||||||
|
|
||||||
With go 1.22 or higher:
|
With go 1.22 or higher:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
go install github.com/cosmtrek/air@latest
|
go install github.com/cosmtrek/air@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### Via install.sh
|
### Via install.sh
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# binary will be $(go env GOPATH)/bin/air
|
# binary will be $(go env GOPATH)/bin/air
|
||||||
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
||||||
|
|
||||||
@@ -62,7 +66,7 @@ air -v
|
|||||||
|
|
||||||
### Via [goblin.run](https://goblin.run)
|
### Via [goblin.run](https://goblin.run)
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
# binary will be /usr/local/bin/air
|
# binary will be /usr/local/bin/air
|
||||||
curl -sSfL https://goblin.run/github.com/cosmtrek/air | sh
|
curl -sSfL https://goblin.run/github.com/cosmtrek/air | sh
|
||||||
|
|
||||||
@@ -72,9 +76,9 @@ curl -sSfL https://goblin.run/github.com/cosmtrek/air | PREFIX=/tmp sh
|
|||||||
|
|
||||||
### Docker/Podman
|
### Docker/Podman
|
||||||
|
|
||||||
Please pull this docker image [cosmtrek/air](https://hub.docker.com/r/cosmtrek/air).
|
Please pull this Docker image [cosmtrek/air](https://hub.docker.com/r/cosmtrek/air).
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker/podman run -it --rm \
|
docker/podman run -it --rm \
|
||||||
-w "<PROJECT>" \
|
-w "<PROJECT>" \
|
||||||
-e "air_wd=<PROJECT>" \
|
-e "air_wd=<PROJECT>" \
|
||||||
@@ -86,9 +90,9 @@ docker/podman run -it --rm \
|
|||||||
|
|
||||||
#### Docker/Podman .${SHELL}rc
|
#### Docker/Podman .${SHELL}rc
|
||||||
|
|
||||||
if you want to use air continuously like a normal app, you can create a function in your ${SHELL}rc (bash,zsh,etc...)
|
if you want to use air continuously like a normal app, you can create a function in your ${SHELL}rc (Bash, Zsh, etc…)
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air() {
|
air() {
|
||||||
podman/docker run -it --rm \
|
podman/docker run -it --rm \
|
||||||
-w "$PWD" -v "$PWD":"$PWD" \
|
-w "$PWD" -v "$PWD":"$PWD" \
|
||||||
@@ -103,19 +107,19 @@ if you want to enter the container, Please add --entrypoint=bash.
|
|||||||
<details>
|
<details>
|
||||||
<summary>For example</summary>
|
<summary>For example</summary>
|
||||||
|
|
||||||
One of my project runs in docker:
|
One of my project runs in Docker:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker run -it --rm \
|
docker run -it --rm \
|
||||||
-w "/go/src/github.com/cosmtrek/hub" \
|
-w "/go/src/github.com/cosmtrek/hub" \
|
||||||
-v $(pwd):/go/src/github.com/cosmtrek/hub \
|
-v $(pwd):/go/src/github.com/cosmtrek/hub \
|
||||||
-p 9090:9090 \
|
-p 9090:9090 \
|
||||||
cosmtrek/air
|
cosmtrek/air
|
||||||
```
|
```
|
||||||
|
|
||||||
Another example:
|
Another example:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
cd /go/src/github.com/cosmtrek/hub
|
cd /go/src/github.com/cosmtrek/hub
|
||||||
AIR_PORT=8080 air -c "config.toml"
|
AIR_PORT=8080 air -c "config.toml"
|
||||||
```
|
```
|
||||||
@@ -130,26 +134,26 @@ For less typing, you could add `alias air='~/.air'` to your `.bashrc` or `.zshrc
|
|||||||
|
|
||||||
First enter into your project
|
First enter into your project
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
cd /path/to/your_project
|
cd /path/to/your_project
|
||||||
```
|
```
|
||||||
|
|
||||||
The simplest usage is run
|
The simplest usage is run
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# firstly find `.air.toml` in current directory, if not found, use defaults
|
# firstly find `.air.toml` in current directory, if not found, use defaults
|
||||||
air -c .air.toml
|
air -c .air.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
You can initialize the `.air.toml` configuration file to the current directory with the default settings running the following command.
|
You can initialize the `.air.toml` configuration file to the current directory with the default settings running the following command.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air init
|
air init
|
||||||
```
|
```
|
||||||
|
|
||||||
After this, you can just run the `air` command without additional arguments and it will use the `.air.toml` file for configuration.
|
After this, you can just run the `air` command without additional arguments, and it will use the `.air.toml` file for configuration.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
air
|
air
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -159,7 +163,7 @@ For modifying the configuration refer to the [air_example.toml](air_example.toml
|
|||||||
|
|
||||||
You can pass arguments for running the built binary by adding them after the air command.
|
You can pass arguments for running the built binary by adding them after the air command.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Will run ./tmp/main bench
|
# Will run ./tmp/main bench
|
||||||
air bench
|
air bench
|
||||||
|
|
||||||
@@ -169,7 +173,7 @@ air server --port 8080
|
|||||||
|
|
||||||
You can separate the arguments passed for the air command and the built binary with `--` argument.
|
You can separate the arguments passed for the air command and the built binary with `--` argument.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Will run ./tmp/main -h
|
# Will run ./tmp/main -h
|
||||||
air -- -h
|
air -- -h
|
||||||
|
|
||||||
@@ -177,7 +181,7 @@ air -- -h
|
|||||||
air -c .air.toml -- -h
|
air -c .air.toml -- -h
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker-compose
|
### Docker Compose
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
@@ -238,7 +242,7 @@ services:
|
|||||||
|
|
||||||
### "command not found: air" or "No such file or directory"
|
### "command not found: air" or "No such file or directory"
|
||||||
|
|
||||||
```zsh
|
```shell
|
||||||
export GOPATH=$HOME/xxxxx
|
export GOPATH=$HOME/xxxxx
|
||||||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||||
export PATH=$PATH:$(go env GOPATH)/bin <---- Confirm this line in you profile!!!
|
export PATH=$PATH:$(go env GOPATH)/bin <---- Confirm this line in you profile!!!
|
||||||
@@ -248,7 +252,7 @@ export PATH=$PATH:$(go env GOPATH)/bin <---- Confirm this line in you profile!!!
|
|||||||
|
|
||||||
Should use `\` to escape the `' in the bin. related issue: [#305](https://github.com/cosmtrek/air/issues/305)
|
Should use `\` to escape the `' in the bin. related issue: [#305](https://github.com/cosmtrek/air/issues/305)
|
||||||
|
|
||||||
### Question: how to do hot compile only and do not run anything?
|
### Question: how to do hot compile only and do not run anything?
|
||||||
|
|
||||||
[#365](https://github.com/cosmtrek/air/issues/365)
|
[#365](https://github.com/cosmtrek/air/issues/365)
|
||||||
|
|
||||||
@@ -263,7 +267,7 @@ Should use `\` to escape the `' in the bin. related issue: [#305](https://github
|
|||||||
Refer to issue [#512](https://github.com/cosmtrek/air/issues/512) for additional details.
|
Refer to issue [#512](https://github.com/cosmtrek/air/issues/512) for additional details.
|
||||||
|
|
||||||
* Ensure your static files in `include_dir`, `include_ext`, or `include_file`.
|
* Ensure your static files in `include_dir`, `include_ext`, or `include_file`.
|
||||||
* Ensure your html has a `</body>` tag
|
* Ensure your HTML has a `</body>` tag
|
||||||
* Activate the proxy by configuring the following config:
|
* Activate the proxy by configuring the following config:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
@@ -277,7 +281,7 @@ Refer to issue [#512](https://github.com/cosmtrek/air/issues/512) for additional
|
|||||||
|
|
||||||
Please note that it requires Go 1.16+ since I use `go mod` to manage dependencies.
|
Please note that it requires Go 1.16+ since I use `go mod` to manage dependencies.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Fork this project
|
# Fork this project
|
||||||
|
|
||||||
# Clone it
|
# Clone it
|
||||||
@@ -297,7 +301,7 @@ Pull requests are welcome.
|
|||||||
|
|
||||||
### Release
|
### Release
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# Checkout to master
|
# Checkout to master
|
||||||
git checkout master
|
git checkout master
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -339,7 +339,7 @@ func (e *Engine) start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cannot set buldDelay to 0, because when the write multiple events received in short time
|
// cannot set buildDelay to 0, because when the write multiple events received in short time
|
||||||
// it will start Multiple buildRuns: https://github.com/cosmtrek/air/issues/473
|
// it will start Multiple buildRuns: https://github.com/cosmtrek/air/issues/473
|
||||||
time.Sleep(e.config.buildDelay())
|
time.Sleep(e.config.buildDelay())
|
||||||
e.flushEvents()
|
e.flushEvents()
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ func TestRebuild(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Logf("port is ready")
|
t.Logf("port is ready")
|
||||||
|
|
||||||
// start rebuld
|
// start rebuild
|
||||||
|
|
||||||
t.Logf("start change main.go")
|
t.Logf("start change main.go")
|
||||||
// change file of main.go
|
// change file of main.go
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ print(os.getcwd())
|
|||||||
os.chdir(os.getcwd() + "\check_rebuild")
|
os.chdir(os.getcwd() + "\check_rebuild")
|
||||||
print(os.getcwd())
|
print(os.getcwd())
|
||||||
|
|
||||||
chlid = PopenSpawn("air")
|
child = PopenSpawn("air")
|
||||||
chlid.expect
|
child.expect
|
||||||
|
|
||||||
a = chlid.expect("running", timeout=300)
|
a = child.expect("running", timeout=300)
|
||||||
if a == 0:
|
if a == 0:
|
||||||
with open("main.go", "a") as f:
|
with open("main.go", "a") as f:
|
||||||
f.write("\n\n")
|
f.write("\n\n")
|
||||||
else:
|
else:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
a = chlid.expect("running", timeout=300)
|
a = child.expect("running", timeout=300)
|
||||||
if a == 0:
|
if a == 0:
|
||||||
print("::set-output name=value::PASS")
|
print("::set-output name=value::PASS")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user