gin 页面重定向
两种gin页面重定向方式 redirect: package main import ( "github.com/gin-gonic/gin" "net/http" ) func main() { r := gin.Default() r.GET("/redirect", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently,"http://www.baidu.com") }) r.Run(":8080") } html rendering: func main() { router := gin.Default() router.LoadHTMLGlob("templates/*") router.GET("/index", func(c *gin.Context) { c.HTML(http.StatusOK, "index.tmpl", gin.H{ "title": "Main website", }) }) router.Run(":8080") } 其中 router.LoadHTMLGlob("templates/*")是设置前端页面目录 来源: https://www.cnblogs.com/wangyuyu/p/12023270.html