golang can be hot updated.
Let’s take a look at using go realize to implement hot updates:
Install realize
Because it was installed in the previous project Gin is used as a web framework, so the routes have been written for later testing.
go get github.com/oxequa/realize
During installation, you may be prompted to fail to install a certain package (starting with golang.org). Don’t panic. These packages can be cloned from the golang warehouse and placed in $GOPATH/src/golang.org /x directory.
Configuration
Run realize init for step-by-step configuration. You can also press Enter all the time, and then refer to my configuration and modify it. The name and path under the schema Please write according to the actual situation. If your machine is a Mac, please replace the process killing command with pkill. This step is very important, otherwise Gin will keep prompting like this when recompiling, causing the hot update to fail.
[GIN-debug] [ERROR] listen tcp :8080: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted
settings: files: outputs: status: false path: "" name: .r.outputs.log logs: status: false path: "" name: .r.logs.log errors: status: true path: "" name: .r.errors.log legacy: force: false interval: 100ms server: status: true open: false port: 8080 host: http://localhost schema: - name: gin_app path: E:/WorkPlace/Go/app/gin_app/ commands: # clean: # status: true # vet: # status: true # fmt: # status: true # test: # status: true # generate: # status: true install: status: true # build: # status: true run: status: true watcher: extensions: - go paths: - / scripts: - type: before command: tskill gin_app output: true ignored_paths: - .git - .realize - vendor
Modify the realize package
Execute the following commands in sequence
cd /go/src/github.com/oxequa/realize git fetch git checkout v2.0.2 go get github.com/oxequa/realize
Go to the project directory and run realize start. Hot update is also normal. .
For more golang knowledge, please pay attention to thegolang tutorialcolumn on the PHP Chinese website.
The above is the detailed content of Can golang be hot updated?. For more information, please follow other related articles on the PHP Chinese website!