From a1f66109e8e39099a605728c54f467578385ddf9 Mon Sep 17 00:00:00 2001 From: M3chD09 Date: Thu, 21 May 2020 23:18:58 +0800 Subject: [PATCH] fix go --- .github/workflows/go.yml | 5 ----- backend/FileHandle/FileSave.go | 2 +- backend/SerialHandle/SerialHandle.go | 2 +- backend/SerialHandle/TestPort.go | 2 +- backend/WebHandle/HandleFunc.go | 6 +++--- build.sh | 9 ++++----- backend/go.mod => go.mod | 0 backend/go.sum => go.sum | 0 backend/main.go => main.go | 8 ++++---- 9 files changed, 14 insertions(+), 20 deletions(-) rename backend/go.mod => go.mod (100%) rename backend/go.sum => go.sum (100%) rename backend/main.go => main.go (88%) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9b53590..93d1be9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,11 +6,6 @@ on: pull_request: branches: [ master ] -defaults: - run: - shell: bash - working-directory: backend - jobs: build: diff --git a/backend/FileHandle/FileSave.go b/backend/FileHandle/FileSave.go index 9c15b54..aad10b1 100644 --- a/backend/FileHandle/FileSave.go +++ b/backend/FileHandle/FileSave.go @@ -6,7 +6,7 @@ import ( "log" "os" - datapack "Robot_Monitor_Web/DataPack" + datapack "Robot_Monitor_Web/backend/DataPack" ) func jsonLoad(filename string, v interface{}) { diff --git a/backend/SerialHandle/SerialHandle.go b/backend/SerialHandle/SerialHandle.go index 246ccff..00f97b8 100644 --- a/backend/SerialHandle/SerialHandle.go +++ b/backend/SerialHandle/SerialHandle.go @@ -7,7 +7,7 @@ import ( "strings" "time" - datapack "Robot_Monitor_Web/DataPack" + datapack "Robot_Monitor_Web/backend/DataPack" "go.bug.st/serial.v1" ) diff --git a/backend/SerialHandle/TestPort.go b/backend/SerialHandle/TestPort.go index 6b13fb7..d12f84e 100644 --- a/backend/SerialHandle/TestPort.go +++ b/backend/SerialHandle/TestPort.go @@ -8,7 +8,7 @@ import ( "go.bug.st/serial.v1" - datapack "Robot_Monitor_Web/DataPack" + datapack "Robot_Monitor_Web/backend/DataPack" ) type testPort struct { diff --git a/backend/WebHandle/HandleFunc.go b/backend/WebHandle/HandleFunc.go index f3ce552..c9b257f 100644 --- a/backend/WebHandle/HandleFunc.go +++ b/backend/WebHandle/HandleFunc.go @@ -10,10 +10,10 @@ import ( "strconv" "strings" - datapack "Robot_Monitor_Web/DataPack" - filehandle "Robot_Monitor_Web/FileHandle" + datapack "Robot_Monitor_Web/backend/DataPack" + filehandle "Robot_Monitor_Web/backend/FileHandle" - serialhandle "Robot_Monitor_Web/SerialHandle" + serialhandle "Robot_Monitor_Web/backend/SerialHandle" ) func currentSerialPortWebHandler(w http.ResponseWriter, _ *http.Request) { diff --git a/build.sh b/build.sh index f33f92a..9055b13 100644 --- a/build.sh +++ b/build.sh @@ -2,16 +2,15 @@ cd ./frontend npm install npm run build -cd ../backend -cp -r ../frontend/dist ./WebPageBuild +cd .. cp main.go main.go.org -sed -i 's/http.Dir(\".\/WebPage\/\")/assetFS()/g' main.go +sed -i 's/http.Dir(\".\/frontend\/dist\/\")/assetFS()/g' main.go #wget -q $(awk -F "\"" '/http(.+?)/{print $2}' WebPageBuild/index.html) -P WebPageBuild #sed -i 's/https[a-zA-Z0-9\:\/\.@\-]*\///g' WebPageBuild/index.html go get github.com/go-bindata/go-bindata/... go get github.com/elazarl/go-bindata-assetfs/... -go-bindata -fs -prefix "WebPageBuild/" WebPageBuild/ -go-bindata-assetfs WebPageBuild/... +go-bindata -fs -prefix "frontend/dist/" frontend/dist/ +go-bindata-assetfs frontend/dist/... CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o Robot_Monitor_Web_linux CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o Robot_Monitor_Web_mac CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o Robot_Monitor_Web_windows.exe diff --git a/backend/go.mod b/go.mod similarity index 100% rename from backend/go.mod rename to go.mod diff --git a/backend/go.sum b/go.sum similarity index 100% rename from backend/go.sum rename to go.sum diff --git a/backend/main.go b/main.go similarity index 88% rename from backend/main.go rename to main.go index be78cc9..48ae1e0 100644 --- a/backend/main.go +++ b/main.go @@ -10,9 +10,9 @@ import ( "strconv" "time" - filehandle "Robot_Monitor_Web/FileHandle" - serialhandle "Robot_Monitor_Web/SerialHandle" - webhandle "Robot_Monitor_Web/WebHandle" + filehandle "Robot_Monitor_Web/backend/FileHandle" + serialhandle "Robot_Monitor_Web/backend/SerialHandle" + webhandle "Robot_Monitor_Web/backend/WebHandle" ) func main() { @@ -31,7 +31,7 @@ func main() { filehandle.SaveAll() } }() - http.Handle("/", http.FileServer(http.Dir("./WebPage/"))) + http.Handle("/", http.FileServer(http.Dir("./frontend/dist/"))) webhandle.Reg() port := "" if len(os.Args) > 1 {