Skip to content

Commit

Permalink
build: move embed to frontend folder
Browse files Browse the repository at this point in the history
  • Loading branch information
nopdan committed Mar 13, 2024
1 parent ef64403 commit f5d8505
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ jobs:
bun install
bun run build
cd ..
mkdir -p pkg/server/dist
mv frontend/dist/* pkg/server/dist/
# 安装 go
- uses: actions/setup-go@v5
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
go.work

build/
pkg/server/dist/
3 changes: 0 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ cd frontend
bun install
bun run build
cd ..
rm pkg/server/dist -r
xcopy frontend\dist\ pkg\server\dist\ /E /Y

go mod tidy

Write-Output "编译 windows 版本"
go build -ldflags="-s -w" -o build/smq.exe
8 changes: 8 additions & 0 deletions frontend/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package frontend

import (
"embed"
)

//go:embed dist
var Dist embed.FS
7 changes: 2 additions & 5 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package server

import (
"embed"
_ "embed"
"encoding/json"
"fmt"
Expand All @@ -12,20 +11,18 @@ import (
"strconv"
"sync"

"github.com/nopdan/gosmq/frontend"
"github.com/nopdan/gosmq/pkg/util"
)

//go:embed dist
var dist embed.FS

// 上传的文件列表
var files [][]byte = make([][]byte, 0)

var textList = make([]string, 0)

func Serve(port int, silent bool, prefix string) {
mux := http.NewServeMux()
dist, _ := fs.Sub(dist, "dist")
dist, _ := fs.Sub(frontend.Dist, "dist")
mux.Handle("GET /", http.FileServer(http.FS(dist)))
mux.HandleFunc("GET /list", func(w http.ResponseWriter, r *http.Request) {
setHeader(&w)
Expand Down

0 comments on commit f5d8505

Please sign in to comment.