This commit is contained in:
陶林 2022-06-20 09:02:40 +08:00
parent 9c57616874
commit 6a2ecee517
4 changed files with 50 additions and 1 deletions

37
gin/1-try/.air.toml Normal file
View File

@ -0,0 +1,37 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
kill_delay = "0s"
log = "build-errors.log"
send_interrupt = false
stop_on_error = true
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
time = false
[misc]
clean_on_exit = false
[screen]
clear_on_rebuild = false

View File

@ -17,4 +17,16 @@ go build -o server main.go
```shell ```shell
go mod vendor go mod vendor
```
### 热更新
```shell
# 安装
go install github.com/cosmtrek/air@latest
# 初始化
air init
# 运行
air -c .air.toml
``` ```

View File

@ -11,7 +11,7 @@ func main() {
context.JSON(200, gin.H{ context.JSON(200, gin.H{
"status": "1", "status": "1",
"message": "请求成功", "message": "请求成功",
"data": "Hello", "data": "Hello333",
}) })
}) })
// 启动HTTP服务默认在0.0.0.0:8080启动服务 // 启动HTTP服务默认在0.0.0.0:8080启动服务

BIN
gin/1-try/tmp/main Executable file

Binary file not shown.