Add: embed web files

This commit is contained in:
2022-12-17 15:55:10 +08:00
parent d52c64d25a
commit 21b2098c78
3 changed files with 19 additions and 3 deletions

14
main.go
View File

@@ -1,8 +1,10 @@
package main
import (
"embed"
"encoding/json"
"flag"
"io/fs"
"log"
"msw-open-music/pkg/api"
"msw-open-music/pkg/commonconfig"
@@ -15,11 +17,21 @@ func init() {
flag.StringVar(&ConfigFilePath, "config", "config.json", "backend config file path")
}
//go:embed web/build
var WEBFILES embed.FS
func main() {
var err error
flag.Parse()
config := commonconfig.Config{}
WEBFS, err := fs.Sub(WEBFILES, "web/build")
if err != nil {
log.Fatal(err)
}
config := commonconfig.Config{
WEBFS: WEBFS,
}
configFile, err := os.Open(ConfigFilePath)
if err != nil {
log.Fatal(err)