项目场景:
go + vue 打包成可执行文件
解决方案:
把打包好的dist文件夹下面的所有文件拷贝到 go项目下
package main
import (
"embed"
"mon/db"
"mon/router"
"net/http"
)
//go:embed index.html favicon.ico css img js fonts
var Static embed.FS
func main() {
// 1.创建路由
r := router.RegisterRouter()
r.StaticFS("/", http.FS(Static))
r.Run(":8006")
defer db.Db.Close()
}
项目打包:
go build main.go