win平台demo

# 工作目录
# 使用 . 或绝对路径,请注意 `tmp_dir` 目录必须在 `root` 目录下
root = "."
tmp_dir = "tmp"

[build]
# 只需要写你平常编译使用的shell命令。你也可以使用 `make`
# Windows平台示例: cmd = "go build -o tmp\main.exe ."
cmd = "go build -o ./tmp/main ."
# 由`cmd`命令得到的二进制文件名
# Windows平台示例:bin = "tmp\main.exe"
bin = "tmp/main"
# 自定义执行程序的命令,可以添加额外的编译标识,比如可以添加 GIN_MODE=release

# 监听以下文件扩展名的文件.
include_ext = ["go", "tpl", "tmpl", "html", "yaml"]
# 忽略这些文件扩展名或目录
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
# 监听以下指定目录的文件
include_dir = []
# 排除以下文件
exclude_file = []
# 如果文件更改过于频繁,则没有必要在每次更改时都触发构建。可以设置触发构建的延迟时间
delay = 800 # ms
# 发生构建错误时,停止运行旧的二进制文件。
stop_on_error = true
# air的日志文件名,该日志文件放置在你的`tmp_dir`中
log = "air_errors.log"

[log]
# 显示时间
time = true

[color]
# 自定义每部分显示的颜色。
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"

[misc]
# 退出时删除tmp目录
clean_on_exit = true

安装

go get -u github.com/cosmtrek/air

使用

# [Air](https://github.com/cosmtrek/air)

# 工作路径
# 使用 .  或 绝对路径, `tmp_dir` 目录必须在 `root` 目录下
root = "."
tmp_dir = "tmp"

[build]
# 只需要写平常编译使用的shell命令。比如可以使用 `make`
# Windows平台示例: cmd = "go build -o tmp\main.exe ."
cmd = "go build -o ./tmp/main ."
# 由`cmd`命令得到的二进制文件名
# Windows平台示例:bin = "tmp\main.exe"
bin = "tmp/main"
# 自定义执行程序的命令,可以添加额外的编译标识例如添加 GIN_MODE=release

# 其实win平台是不需要下面这句话的。
# Windows平台示例:full_bin = "tmp\main.exe"
# full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
# windows此配置要注释,不然热更新后会报端口占用full_bin =""
# full_bin = "tmp\main.exe"
# full_bin = ".tmp/main ./config.yaml"  # linux

# 监听以下文件扩展名的文件
include_ext = ["go", "tpl", "tmpl", "html", "yaml", "css", "js"]
# 忽略这些文件扩展名或目录
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
# 监听以下指定目录的文件
include_dir = []
# 排除以下文件
exclude_file = []

# 如果文件更改过于频繁,则没有必要在每次更改时都触发构建。可以设置触发构建的延迟时间
delay = 800 # ms
# 构建错误时,停止运行旧的二进制文件。
stop_on_error = true
# air的日志文件名,该日志文件放在`tmp_dir`中
log = "air_errors.log"

[log]
# 显示时间
time = true

[color]
# 自定义每个部分显示的颜色显示日志。
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"

[misc]
# 退出时删除tmp目录
clean_on_exit = true
分类: go

站点统计

  • 文章总数:309 篇
  • 分类总数:19 个
  • 标签总数:191 个
  • 运行天数:1009 天
  • 访问总数:129710 人次

浙公网安备33011302000604

辽ICP备20003309号