Go Air 热重载工具使用指南

介绍 Go Air 热重载工具的安装、初始化和配置方法,提升本地开发与调试效率。

用fresh用腻了,想使用air尝尝鲜,上Github一看,air的知名度比fresh高很多,于是直接开始吧。

直接安装

项目地址:https://github.com/air-verse/air

bash
go install github.com/air-verse/air@latest

开始使用

初始化

bash
air init

然后项目根目录就会多出一个.air.toml

修改配置文件

编译位置

toml
cmd = "go build -o ./tmp/main.exe ./cmd/." # 根据main.go所在位置修改,如果为根目录设置为'.',当前main.go位于cmd文件夹中

退出air删除exe

toml
[misc]
  clean_on_exit = true # 在退出air的时候删除编译的exe

完整配置文件

运行

bash
air # 默认直接读取.air.toml的配置
bash
air -c config.toml # 指定配置文件
Go Cache 单机缓存使用与原理
已抵达博客尽头