当前位置:网站首页>Go --- automatic recompilation of air
Go --- automatic recompilation of air
2022-07-27 20:53:00 【Fallacious】
Catalog
0、Air Introduce
Monitor the code file of the project in real time , Automatically recompile and execute after code changes . In the use of Go Linguistic gin When the framework is developed and debugged locally , It is often necessary to press... Frequently after changing the code Ctrl+C Stop the program and recompile and execute , This is not very convenient .
github Address :https://github.com/cosmtrek/air
Reference link :https://www.liwenzhou.com/posts/Go/live_reload_with_air/
1、 install
go install github.com/cosmtrek/[email protected]
2、 initialization
air init
Default generation configuration file .air.toml, The contents are as follows :
root = "."
testdata_dir = "testdata"
# Log storage location
tmp_dir = "tmp"
[build]
args_bin = []
# Start command
bin = "./tmp/main"
# compile
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
Modify logs as needed 、 Compile file location 、 Execute the command after compilation
3、 Ready to serve
A simple demo
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
r := gin.Default()
r.GET("/hello", func(c *gin.Context) {
c.String(http.StatusOK, "mio")
})
_ = r.Run(":9090")
}
4、 Start the service
air

Monitoring at this time 9090 port
5、 Test real-time loading
Set the port number 9090 Change it to 9091 After saving , See whether the terminal is recompiled

After the modification is saved, the service is recompiled and started , The listening port number changes to 9091, Test success
If there is any wrong , Please point out , thank ~
边栏推荐
- [deep learning] pytoch tensor
- 用户和权限限制用户使用资源
- [Numpy] 数组属性
- 走马灯案例
- 【效率】弃用 Notepad++,这款开源替代品更牛逼!
- Laboratory management system implemented by SSM framework +jsp [source code + database + system paper]
- 国际权威认可!OceanBase入选Forrester Translytical数据平台报告
- Scrollintoview realizes simple anchor location (example: select city list)
- Flask Mdict builds online MDICT Dictionary Service
- Tencent jumped out with 38K and saw the real test ceiling
猜你喜欢

Introduction to JVs Foundation
![(manual) [sqli labs38, 39] stack injection, error echo, character / number type](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
(manual) [sqli labs38, 39] stack injection, error echo, character / number type

EasyCVR平台关闭录像为何还会有TS切片文件生成?

Lennix Lai, OKx financial market director: Web3 is a revolution
![[Numpy] 数组索引和切片](/img/ce/34db7aef3fefe8a03e638d0838492f.png)
[Numpy] 数组索引和切片

【毕设教程】YOLOv7 目标检测网络解读

基于ATX自动化测试解决方案

Tencent jumped out with 38K and saw the real test ceiling

Jetpack Compose 性能优化指南——编译指标

Arduino开发(二)_基于Arduino UNO开发板的RGB灯光控制方法
随机推荐
Best practices for Oracle kingbasees migration of Jincang database (4. Oracle database migration practice)
After working for bytek for two years, he got 15 offers at one go
Onion group joined hands with oceanbase to realize distributed upgrading, and global data has achieved cross cloud integration for the first time
金仓数据库 KingbaseES 异构数据库移植指南 (4. 应用迁移流程)
Scrollintoview realizes simple anchor location (example: select city list)
2022.07.11
Xdc 2022 Intel technology special session: Intel Software and hardware technology builds the cornerstone of cloud computing architecture
Arduino开发(二)_基于Arduino UNO开发板的RGB灯光控制方法
【分层强化学习】HAC论文及代码
What app should individuals use for stock speculation to be safer and faster
adb shell ls /system/bin(索引表)
How to optimize the open source community experience through developer metrics
Flask Mdict builds online MDICT Dictionary Service
MySQL驱动jar包的下载--保姆教程
Nailing development document
Openresty Lua resty DNS domain name resolution
[Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration
JVS基础介绍
[deep learning] pytoch tensor
Openresty Lua resty core use