golang 嵌入式ARM7(压缩编译打包)
编译 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

qq:505645074

浙公网安备 33010602011771号