41 lines
897 B
Batchfile
41 lines
897 B
Batchfile
@echo off
|
||
chcp 65001 > nul
|
||
setlocal
|
||
|
||
REM 设置配置文件路径环境变量
|
||
set CONFIG_PATH=config.yaml
|
||
|
||
REM 询问用户要打包成 Windows 还是 Linux
|
||
set /p OS="请选择要打包成的操作系统 (windows/linux): "
|
||
if /i "%OS%"=="windows" (
|
||
set GOOS=windows
|
||
set EXECUTABLE=qnc.exe
|
||
) else if /i "%OS%"=="linux" (
|
||
set GOOS=linux
|
||
set EXECUTABLE=qnc
|
||
) else (
|
||
echo 无效的选项,请选择 windows 或 linux
|
||
exit /b 1
|
||
)
|
||
|
||
REM 创建打包文件夹
|
||
mkdir dist
|
||
|
||
|
||
REM 交叉编译成对应的操作系统和架构
|
||
set GOARCH=amd64
|
||
go build -o dist/%EXECUTABLE% main.go
|
||
|
||
|
||
|
||
REM 将配置文件复制到打包文件夹
|
||
@REM copy config.yaml dist\config.yaml
|
||
@REM copy processed.json dist\processed.json
|
||
@REM xcopy ssl dist\ssl /E /I /Y
|
||
xcopy templates dist\templates /E /I /Y
|
||
xcopy merchant dist\merchant /E /I /Y
|
||
|
||
echo "打包完成,文件夹已生成:dist"
|
||
|
||
endlocal
|