diff --git a/gin/1-try/.air.toml b/gin/1-try/.air.toml new file mode 100644 index 0000000..5e0318c --- /dev/null +++ b/gin/1-try/.air.toml @@ -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 diff --git a/gin/1-try/README.md b/gin/1-try/README.md index 4bfb4b0..195848b 100644 --- a/gin/1-try/README.md +++ b/gin/1-try/README.md @@ -17,4 +17,16 @@ go build -o server main.go ```shell go mod vendor +``` + +### 热更新 + +```shell +# 安装 +go install github.com/cosmtrek/air@latest + +# 初始化 +air init +# 运行 +air -c .air.toml ``` \ No newline at end of file diff --git a/gin/1-try/main.go b/gin/1-try/main.go index f1df727..3f9eb91 100644 --- a/gin/1-try/main.go +++ b/gin/1-try/main.go @@ -11,7 +11,7 @@ func main() { context.JSON(200, gin.H{ "status": "1", "message": "请求成功", - "data": "Hello", + "data": "Hello333", }) }) // 启动HTTP服务,默认在0.0.0.0:8080启动服务 diff --git a/gin/1-try/tmp/main b/gin/1-try/tmp/main new file mode 100755 index 0000000..bd18772 Binary files /dev/null and b/gin/1-try/tmp/main differ