Files
GoCode/main.go
nannanwu 8155bd710b gin路由分组 路由文件抽离
gin自定义控制器 实现控制器的继承
2025-12-03 22:19:24 +08:00

32 lines
590 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"awesomeProject/router"
"github.com/gin-gonic/gin"
)
// main 函数是程序的入口点初始化并启动Web服务器
func main() {
// 创建默认的gin引擎
r := gin.Default()
// 加载模板文件,支持多层目录结构
r.LoadHTMLGlob("templates/**/*")
// 配置静态文件目录,将./static目录映射到URL路径/static
r.Static("/static", "./static")
router.AdminRouterInit(r)
router.ApiRouterInit(r)
router.DefaultRouterInit(r)
// 启动HTTP服务器监听在8081端口
err := r.Run(":8088")
if err != nil {
return
}
}