Hot deployment of gin framework (hot loading)


Hot loading and hot deployment mean real-time loading
When we modify the code, the program can be automatically reloaded and executed, which is very convenient in our development. We can quickly test the code and save every manual recompilation.
There are about six methods for hot loading the gin framework. I’ll just talk about one fresh plug-in here

Fresh installation

Using the install command

go install[email protected]

If you have already configured the go proxy, this step should be finished soon. If not configured, use the following two commands

go env -w GOPROXY=,direct
go env -w GO111MODULE=on


In your project directory (not gopath) but a project under SRC under gopath, use the command fresh


For example, my gopath is D: \ go_ Project, the directory where I use fresh is D: \ go_ project\src\test

Hot deployment of gin framework (hot loading)


be careful

Before you use the fresh command, please make sure to turn off the web service of the previous gin framework (if it is turned on before), otherwise the port will be occupied.
There cannot be more than one package main under the same directory. If there are other demos or other codes with package main under the project directory, please change the location of the redundant code files. Otherwise, an error will be reported when running the fresh command

Hot deployment of gin framework (hot loading)