gocron原始碼中使用的是馬卡龍框架,下面這個就是安裝這個框架,和一般的MVC框架很像
go get gopkg.in/macaron.v1
git clone https://github.com/golang/crypto.git $GOPATH/src/golang.org/x/crypto
監聽80埠,使用模板引擎的簡單例子
package mainimport "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 ,名字和你呼叫模板的名字對應
index.tmpl
<h2>{{.Name}}</h2>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/63350.html
標籤:Go
