编译 Go 应用程序
go build -ldflags="-s -w" -o myapp.exe .
使用 UPX 压缩可执行文件(window下载并设置环境变量)
upx --best --lzma myapp.exe
可从10M压缩到1M
@echo off REM Set Go environment variables set CGO_ENABLED=0 set GOOS=linux set GOARCH=arm set GOARM=7 REM Compile the Go program echo Compiling Go program... go build -ldflags "-s -w" REM Check if the compilation was successful IF ERRORLEVEL 1 ( echo Compilation failed, please check the code. pause exit /B 1 ) echo Compilation successful, packing files... REM Use 7-Zip to package files "C:\Program Files\7-Zip\7z.exe" a bin\tboxconfig_arm7.tar tboxconfig wwwroot config.json IF ERRORLEVEL 1 ( echo Packaging failed, please check if the folder and files exist. pause exit /B 1 ) echo Packaging successful, generated file is tboxconfig_arm7.zip pause exit /B 0
标签:files,set,压缩,echo,golang,编译,pause,REM,Go From: https://www.cnblogs.com/chen1880/p/18554544