Last active
July 30, 2019 22:26
-
-
Save soypat/028558f59baab95e9785e9c8b1efc5f4 to your computer and use it in GitHub Desktop.
Deploy go code for multiple architectures
This file contains 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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What it do:
Heres a list of supported architectures and OS!