Skip to content

Instantly share code, notes, and snippets.

@dmoruzzi
Created May 27, 2024 00:59
Show Gist options
  • Save dmoruzzi/95f88b88b00df4292717904be0550510 to your computer and use it in GitHub Desktop.
Save dmoruzzi/95f88b88b00df4292717904be0550510 to your computer and use it in GitHub Desktop.
Build a Go program for Linux ARM64
@echo off
REM Set Go environment variables for Linux ARM64
set GOARCH=arm64
set GOOS=linux
REM Define the output binary name
set OUTPUT_BINARY=myapp
REM Build the Go program
echo Building the Go program for Linux ARM64...
go build -o %OUTPUT_BINARY%
REM Check if the build was successful
if %ERRORLEVEL% neq 0 (
echo Build failed!
exit /b %ERRORLEVEL%
)
echo Build successful!
REM Optional: If you have an ARM64 environment to run the binary, you can add commands to deploy and run it.
REM For example, using SSH to copy and run the binary on a remote ARM64 device.
REM set REMOTE_USER=pi
REM set REMOTE_HOST=raspberrypi
REM set REMOTE_PATH=/tmp/ # /path/to/deploy
REM echo Copying binary to remote ARM64 device...
REM scp %OUTPUT_BINARY% %REMOTE_USER%@%REMOTE_HOST%:%REMOTE_PATH%
REM echo Running binary on remote ARM64 device...
REM ssh %REMOTE_USER%@%REMOTE_HOST% "cd %REMOTE_PATH% && ./%OUTPUT_BINARY%"
echo Done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment