Skip to content

Instantly share code, notes, and snippets.

@jonforums
Last active December 21, 2015 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonforums/6273338 to your computer and use it in GitHub Desktop.
Save jonforums/6273338 to your computer and use it in GitHub Desktop.
Build Go from source using PowerShell
# Author: Jon Maken, All Rights Reserved
# License: 3-clause BSD
# Revision: 2014-04-05 17:44:19 -0600
$toolkit = 'C:\Apps\DevTools\msys32\mingw64\bin'
$targets = 'windows:amd64:1', 'windows:386:0',
'linux:amd64:0', 'linux:386:0',
'darwin:amd64:0', 'darwin:386:0'
$orig_path = $env:PATH
$env:PATH = "$toolkit;$env:PATH"
Push-Location src
$targets | % {
$env:GOOS, $env:GOARCH, $env:CGO_ENABLED = $_.Split(':')
switch ($env:CGO_ENABLED) {
'0' { $cmd = 'make.bat --no-clean' }
'1' { $cmd = 'all.bat' }
}
Write-Host "`n---> building for $env:GOOS/$env:GOARCH platform`n" `
-foregroundcolor yellow
Invoke-Expression ".\$cmd"
}
Pop-Location
Remove-Item env:GOOS, env:GOARCH, env:CGO_ENABLED
$env:PATH = $orig_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment