package static import ( "embed" "io/fs" "net/http" "sync" ) //go:embed static var staticFS embed.FS var ( indexHTML []byte once sync.Once ) func GetIndex() []byte { once.Do(func() { data, _ := fs.ReadFile(staticFS, "static/index.html") indexHTML = data }) return indexHTML } func Handler() http.Handler { sub, _ := fs.Sub(staticFS, "static") return http.FileServer(http.FS(sub)) }