在开发项目的过程中,如果总是要去重启服务,编译代码,总使一个繁琐的过程。
当然,我们可以利用一些库协助我们热加载开发,不需要重复去重启服务了。
工具 1(推荐):https://github.com/gravityblast/fresh
- # 下载依赖库
- go get github.com/pilu/fresh
-
- # 使用热加载启动服务
- $ fresh
工具 2:https://github.com/codegangsta/gin
- # 下载依赖库
- go get -u github.com/codegangsta/gin
-
- # 使用方法
- $ gin run main.go
go get github.com/pilu/fresh
$ fresh
- PS D:\goProject\go-gin-practice> fresh
- fresh : 无法将“fresh”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
- 所在位置 行:1 字符: 1
- + fresh
- + ~~~~~
- + CategoryInfo : ObjectNotFound: (fresh:String) [], CommandNotFoundException
- + FullyQualifiedErrorId : CommandNotFoundException
-
- PS D:\goProject\go-gin-practice>
- # 从github下载最新的代码
- git clone https://github.com/gravityblast/fresh.git
- # 或者使用码云下载
- git clone git@gitee.com:kubernete/fresh.git
- # 安装fresh
- go install github.com/pilu/fresh@latest