This commit is contained in:
2023-03-10 08:47:01 +08:00
parent 694b561c01
commit c833d1864e
+5 -8
View File
@@ -16,11 +16,8 @@ import (
"github.com/joho/godotenv" "github.com/joho/godotenv"
) )
//go:embed statics/**/* //go:embed tmpl/* statics/**/*
var staticFS embed.FS var f embed.FS
//go:embed tmpl/*
var tplFS embed.FS
func main() { func main() {
@@ -32,10 +29,10 @@ func main() {
r := Router() r := Router()
// 静态文件也打包 // 静态文件也打包
tmpl, _ := template.ParseFS(tplFS, "tmpl/*") tmpl, _ := template.ParseFS(f, "tmpl/*")
r.SetHTMLTemplate(tmpl) r.SetHTMLTemplate(tmpl)
staticFS, _ := fs.Sub(staticFS, "static") staticsFS, _ := fs.Sub(f, "statics")
r.StaticFS("/static", http.FS(staticFS)) r.StaticFS("/statics", http.FS(staticsFS))
//r.LoadHTMLGlob("tmpl/*") //r.LoadHTMLGlob("tmpl/*")
//r.Static("/statics", "./statics") //r.Static("/statics", "./statics")