Skip to content

Instantly share code, notes, and snippets.

@soypat
Last active July 30, 2019 22:26
Show Gist options
  • Save soypat/028558f59baab95e9785e9c8b1efc5f4 to your computer and use it in GitHub Desktop.
Save soypat/028558f59baab95e9785e9c8b1efc5f4 to your computer and use it in GitHub Desktop.
Deploy go code for multiple architectures
@ECHO OFF
ECHO.
ECHO Start building...
ECHO.
:: Comment: -ldflags reduces the binary file size by omitting symbol tables and debug information. Useful when deploying.
:: All caps on keywords not necessary.
SET GOOS=linux
SET GOARCH=amd64
go build -ldflags="-s -w" -i -o "main_linux" main.go
ECHO Linux build finished.
ECHO.
SET GOOS=darwin
SET GOARCH=amd64
go build -ldflags="-s -w" -i -o "main_macOS" main.go
ECHO MacOS build finished.
ECHO.
SET GOOS=windows
SET GOARCH=amd64
go build -ldflags="-s -w" -i -o "main_win64.exe" main.go
ECHO Win64 build finished.
ECHO.
SET GOOS=windows
SET GOARCH=386
go build -ldflags="-s -w" -i -o "main_win32.exe" main.go
ECHO Win32 build finished.
ECHO.
ECHO Done.
PAUSE
@soypat
Copy link
Author

soypat commented Apr 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment