当前位置:网站首页>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 ~
边栏推荐
- UE5使用DLSS(超级采样)提升场景的 FPS 远离卡顿的优化方案
- 做测试, 就得去大厂,内部披露BAT大厂招聘“潜规则”
- [dataset display annotation] VOC file structure + dataset annotation visualization + code implementation
- JVS私有化部署启动失败处理方案
- Software test interview question: count the number in a queue, how many positive numbers and how many negative numbers, such as [1, 3, 5, 7, 0, -1, -9, -4, -5, 8]
- 面了个腾讯拿38K跳槽出来的,见识到了真正的测试天花板
- 全局样式与图标
- Kingbasees heterogeneous database migration guide (3. Kingbasees migration capability support system)
- 【深度学习】视频分类技术整理
- Onion group joined hands with oceanbase to realize distributed upgrading, and global data has achieved cross cloud integration for the first time
猜你喜欢

五大知名人士对于AI的忧虑

RK3399平台入门到精通系列讲解(导读篇)21天学习挑战介绍

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

征服所有程序员的3件IT装备 →

如何监控NVIDIA Jetson的的运行状态和使用情况
![[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

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

Download of MySQL driver jar package -- nanny tutorial

Flask Mdict builds online MDICT Dictionary Service

Flask-MDict搭建在线Mdict词典服务
随机推荐
金仓数据库 KingbaseES异构数据库移植指南 (2. 概述)
Software test interview question: string "axbyczdj", if you get the result "ABCD"
JVS基础框架功能列表
一文了解Pycharm快捷键
Ten year test old bird talk about mobile terminal compatibility test
用户组织架构的管理
人家这才叫软件测试工程师,你那只是混口饭吃(附HR面试宝典)
未定义变量 “Lattice“ 或类 “Lattice.latticeEasy“(Matlab)
十年测试老鸟聊聊移动端兼容性测试
User and authority modify user password
软件测试面试题:已知一个字符串为“hello_world_yoyo”, 如何得到一个队列 [“hello“,“world“,“yoyo“]
One week activity express | in simple terms, issue 8; Meetup Chengdu station registration in progress
A recently summarized universal violent cracking method
【程序人生】“阶段总结“-不甘平凡
RK3399平台入门到精通系列讲解(导读篇)21天学习挑战介绍
在字节干了两年离职后,一口气拿到15家Offer
VI working mode (3 kinds) and mode switching (conversion)
Lennix Lai, OKx financial market director: Web3 is a revolution
Interviewer: what is the abstract factory model?
Laboratory management system implemented by SSM framework +jsp [source code + database + system paper]