Air hot-loading Golang code

Install

go get github.com/cosmtrek/air

use

  1. air initCreate a default configuration file under the project.air.toml
  2. Adjust configuration items
  cmd = "go build -o tmp/${PWD##*/} ." #编译命令,二进制以项目为名输出到tmp目录下
  bin = "tmp/${PWD##*/}" #二进制导出路径
  include_ext = ["go", "html"] #监控文件类型
  exclude_dir = ["tmp", "vendor"] #监控剔除目录

  tmp_dir = "tmp" #air临时文件输出目录(需要git忽略)

  clear_on_rebuild = true
  1. Start hot reload monitoringair [-c .air.toml]
{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324200259&siteId=291194637