当前位置:网站首页>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 ~
边栏推荐
- 【程序人生】“阶段总结“-不甘平凡
- 用户和权限限制用户使用资源
- MySQL string function
- SLIM:自监督点云场景流与运动估计(ICCV 2021)
- JVs official account login configuration
- 在字节干了两年离职后,一口气拿到15家Offer
- RK3399平台入门到精通系列讲解(导读篇)21天学习挑战介绍
- [design tutorial] yolov7 target detection network interpretation
- (manual) [sqli labs38, 39] stack injection, error echo, character / number type
- Openresty Lua resty core use
猜你喜欢

leetcode:1498. 满足条件的子序列数目【排序 + 二分 + 幂次哈希表】

一个程序员的水平能差到什么程度?

To do the test, you have to go to the big factory and disclose the "hidden rules" of bat big factory recruitment internally
![[benefit activity] stack a buff for your code! Click](/img/2d/dabf0ad5d7bd553dada5921abf6c06.png)
[benefit activity] stack a buff for your code! Click "tea" to receive the gift

从0开始写bootloader

JVs privatization deployment start failure handling scheme

【效率】弃用 Notepad++,这款开源替代品更牛逼!

go --- air自动重新编译

Why does Alibaba prohibit more than three forms from joining?

一周活动速递|深入浅出第8期;Meetup成都站报名进行中
随机推荐
Arduino开发(二)_基于Arduino UNO开发板的RGB灯光控制方法
Swiftui view onReceive method receives "redundant" event resolution
Scrollintoview realizes simple anchor location (example: select city list)
MySQL 日志查询日志
Is it safe for CICC fortune to open an account? What is the use of opening an account
Management of user organization structure
软件测试面试题:已知一个数字为1,如何输出“0001
做测试, 就得去大厂,内部披露BAT大厂招聘“潜规则”
认识传输介质网络通信的介质
力扣解法汇总592-分数加减运算
sql编码bug
adb shell ls /system/bin(索引表)
go --- air自动重新编译
用户和权限撤销用户权限
EasyCVR平台添加RTSP设备时,出现均以TCP方式连接的现象是什么原因?
征服所有程序员的3件IT装备 →
金仓数据库 KingbaseES异构数据库移植指南 (2. 概述)
Introduction to JVs Foundation
js中数组与字符串常用方法属性总结
Xdc 2022 Intel technology special session: Intel Software and hardware technology builds the cornerstone of cloud computing architecture