github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/controller/view.go (about) 1 package main 2 3 import ( 4 "github.com/gogf/gf/frame/g" 5 "github.com/gogf/gf/frame/gmvc" 6 ) 7 8 type Controller struct { 9 gmvc.Controller 10 } 11 12 func (c *Controller) Index() { 13 c.View.Assign("name", "john") 14 c.View.Assign("mainTpl", "main/main2.html") 15 c.View.Display("layout.html") 16 } 17 18 func main() { 19 s := g.Server() 20 s.BindController("/view", new(Controller)) 21 s.SetPort(8199) 22 s.Run() 23 }