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"
)
//go:embed statics/**/*
var staticFS embed.FS
//go:embed tmpl/*
var tplFS embed.FS
//go:embed tmpl/* statics/**/*
var f embed.FS
func main() {
@@ -32,10 +29,10 @@ func main() {
r := Router()
// 静态文件也打包
tmpl, _ := template.ParseFS(tplFS, "tmpl/*")
tmpl, _ := template.ParseFS(f, "tmpl/*")
r.SetHTMLTemplate(tmpl)
staticFS, _ := fs.Sub(staticFS, "static")
r.StaticFS("/static", http.FS(staticFS))
staticsFS, _ := fs.Sub(f, "statics")
r.StaticFS("/statics", http.FS(staticsFS))
//r.LoadHTMLGlob("tmpl/*")
//r.Static("/statics", "./statics")