公司为了提高研发效率,想要让我搞一下热部署,然后就上网上查热部署,发现有好多工具可以完成这个效果,就挑了一个比较不错的air,使用过后也是感觉非常不错的,下面来说说怎么用。
先说一下air的特性:
1)彩色日志输出
2)自定义构建或二进制命令
3)支持忽略子目录
4)启动后支持监听新目录
5)更好的构建过程
安装:
在命令行中输入go get -u github.com/cosmtrek/air
使用:
alias air='~/.air'.bashrc.zshrcalias air='~/.air'vim ~/.zshrc
# 1. 进入你自己的项目目录
$ cd /your_project
# 2. 查找你的项目中是否存在 `.air.conf` 配置文件
$ air -c .air.conf
# 3. 没有则创建一个
$ touch .air.conf
# 4. 复制下面示例 `air.conf.example`到你的 `.air.conf`
# 5. 启动热加载
$ air
# 6. 启动热加载 带打印log
$ air -d
air.conf.example示例
root = "."
tmp_dir = "tmp"
[build]
# Just plain old shell command. You could use `make` as well.
cmd = "go build -o ./tmp/main ."
# Binary file yields from `cmd`.
bin = "tmp/main"
# Customize binary.
full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
# Watch these filename extensions.
include_ext = ["go", "tpl", "tmpl", "html"]
# Ignore these filename extensions or directories.
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
# Watch these directories if you specified.
include_dir = []
# Exclude files.
exclude_file = []
# This log file places in your tmp_dir.
log = "air.log"
# It's not necessary to trigger build each time file changes if it's too frequent.
delay = 1000 # ms
# Stop running old binary when build errors occur.
stop_on_error = true
# Send Interrupt signal before killing process (windows does not support this feature)
send_interrupt = false
# Delay after sending Interrupt signal
kill_delay = 500 # ms
[log]
# Show log time
time = false
[color]
# Customize each part's color. If no color found, use the raw app log.
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"
[misc]
# Delete tmp directory on exit
clean_on_exit = true
原文链接:https://blog.csdn.net/qq_39397165/article/details/108025397