1、Windows版的打包
创建一个文件 go_build.txt
写入内容
::删除release文件夹
rd /s/q release
::创建release文件夹
md release
::去掉启动时的黑框
go build -ldflags "-H windowsgui" -o go_build.exe
::构建
::go build -o go_build.exe
COPY go_build.exe release\
COPY favicon.ico release\favicon.ico
::将静态页面及样式拷贝带release
XCOPY asset\*.* release\asset\ /s /e
XCOPY view\*.* release\view\ /s /e
将go_build.txt更名为go_build.bat,放入main.go同等目录中执行即可
2、Linux打包
创建一个sh文件 go_build.sh
写入内容
#!/bin/sh
rm -rf ./release
mkdir release
go build -o go_build
chmod +x ./go_build
cp go_build ./release/
cp favicon.ico ./release/
cp -ar ./asset ./release/
cp -ar ./view ./release/
sh go_build.sh 执行即可
网友评论