main.go
package main
import (
"github.com/xiuno/gin"
"net/http"
)
func main() {
r := gin.Default()
r.LoadHTMLGlob("view/*")
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{
"title": "hello Go",
})
})
r.Run()
}
view/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ .title }}</title>
</head>
<body>
<h1>{{ .title }}</h1>
</body>
</html>