hello.go
package main
import (
"github.com/gin-gonic/gin"
)
func Hello(ctx *gin.Context){
name:="zhangsan"
ctx.HTML(200,"index.html",name)
}
func main() {
router := gin.Default()
router.LoadHTMLGlob("template/*")
router.GET("/index/a/1",Hello)
router.Run(":8001")
}
template/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
</head>
<body>
<h1>Index:{{.}}</h1>
</body>
</html>