GolangbuildGofresh

安装

go get github.com/pilu/fresh

使用

进入项目根目录

cd $GOPATH/src/fresh_test
fresh
fresh

这时控制台就开始编译打包执行了,注意控制台返回的信息,能知道项目的编译错误和日志,最后会有访问 url,

gofreshreload

来实践一下

main.go
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,"Hello Fresh!")
})
    r.Run()
}

使用fresh类库实现Go gin热重启_golang

freshcurl
[fuzqing@localhost ~]$ curl -XGET http://localhost:8080/hello
Hello Fresh!
main.go
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,"Hello Fresh!\nReload")
})
    r.Run()
}
gofreshreload

使用fresh类库实现Go gin热重启_第三方类库_02

[fuzqing@localhost ~]$ curl -XGET http://localhost:8080/hello
Hello Fresh!
Reload

END~