File size: 481 Bytes
6236305 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | package main
import (
"embed"
"io/fs"
"net/http"
)
//go:embed templates/*
var templatesFS embed.FS
//go:embed static/*
var staticFS embed.FS
// GetTemplatesFS 返回嵌入的模板文件系统
func GetTemplatesFS() embed.FS {
return templatesFS
}
// GetStaticFS 返回嵌入的静态文件系统
func GetStaticFS() http.FileSystem {
staticSubFS, err := fs.Sub(staticFS, "static")
if err != nil {
panic(err)
}
return http.FS(staticSubFS)
}
|