gocron源碼中使用的是馬卡龍框架,下面這個就是安裝這個框架,和通常的MVC框架很像
go get gopkg.in/macaron.v1
git clone https://github.com/golang/crypto.git $GOPATH/src/golang.org/x/cryptogit
監聽80端口,使用模板引擎的簡單例子github
package main import "gopkg.in/macaron.v1" func main() { m := macaron.Classic() //使用模板引擎 m.Use(macaron.Renderer()) m.Get("/", func(ctx *macaron.Context) { ctx.Data["Name"] = "taoshihan" ctx.HTML(200, "index") // 200 爲響應碼 }) m.Run("0.0.0.0", 80) }
在當前目錄下建立 templates/ , xxx.tmpl ,名字和你調用模板的名字對應golang
index.tmpl框架
<h2>{{.Name}}</h2>