Created
September 25, 2024 20:10
-
-
Save parsibox/3a4cbbc4eca8bc2e66a59972f8bcb4da to your computer and use it in GitHub Desktop.
build compress linux output fast with one click in windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM Find the first Go file in the folder | |
for %%f in (*.go) do ( | |
set GOFILE=%%f | |
goto :found | |
) | |
:found | |
if not defined GOFILE ( | |
echo No Go file found in the current directory. | |
pause | |
exit /b 1 | |
) | |
echo Found Go file: %GOFILE% | |
echo Building for Linux... | |
REM Set the environment variables for Linux build | |
set GOOS=linux | |
set GOARCH=amd64 | |
REM Build the Go file for Linux | |
go build -ldflags "-s -w" -o output_linux %GOFILE% | |
if %errorlevel% neq 0 ( | |
echo Build failed. | |
pause | |
exit /b 1 | |
) | |
C:\portable\upx-4.0.2-win64\upx.exe output_linux | |
echo Build successful! Output: output_linux | |
timeout /t 2 >nul | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment