gocron源码中使用的是马卡龙框架,下面这个就是安装这个框架,和一般的MVC框架很像
go get gopkg.in/macaron.v1
git clone https://github.com/golang/crypto.git $GOPATH/src/golang.org/x/crypto

监听80端口,使用模板引擎的简单例子

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 ,名字和你调用模板的名字对应

index.tmpl

<h2>{{.Name}}</h2>

 

相关文章:

  • 2021-06-13
  • 2021-07-05
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2021-11-01
  • 2022-02-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案