Skip to content

Instantly share code, notes, and snippets.

@dlsniper
Created January 28, 2016 09:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dlsniper/6027dba0291f1287f3f4 to your computer and use it in GitHub Desktop.
Save dlsniper/6027dba0291f1287f3f4 to your computer and use it in GitHub Desktop.
Install go
$cwd = $PSScriptRoot+"\"
$gosdk = $cwd+"go"
$zip7 = $cwd+"7z"
$mingw = $cwd+"mingw64"
$gitdir = $cwd+"git"
$gopath = $cwd+"gopath"
# Install Go
if (-Not (Test-Path $gosdk)) {
echo "Installing Go into: "$gosdk
$file = "go1.5.3.windows-amd64.msi"
$url = "https://storage.googleapis.com/golang/"
$url += $file
Invoke-WebRequest -UserAgent wget -Uri $url -OutFile $file
msiexec INSTALLDIR=$gosdk TARGETDIR=$gosdk /package $file /quiet | Out-Null
rm $file
} else {
echo "Go already installed"
}
# Install 7Zip
if (-Not (Test-Path $zip7)) {
echo "Installing 7Zip into: "$zip7
$file = "7z1514-x64.msi"
$url = "http://7-zip.org/a/"
$url += $file
Invoke-WebRequest -UserAgent wget -Uri $url -OutFile $file
msiexec INSTALLDIR=$zip7 TARGETDIR=$zip7 /package $file /quiet | Out-Null
rm $file
} else {
echo "7Zip already installed"
}
# Install MinGW
if (-Not (Test-Path $mingw)) {
echo "Installing MinGW into"$mingw
$file = "x86_64-4.9.2-release-win32-seh-rt_v4-rev3.7z"
$url = "https://bintray.com/artifact/download/drewwells/generic/"
$url += $file
Invoke-WebRequest -UserAgent wget -Uri $url -OutFile $file
&$zip7\7z.exe x $file > $null
rm $file
} else {
echo "MinGW is already installed"
}
# Install git
if (-Not (Test-Path $gitdir)) {
echo "Installing git to "$gitdir
$file = "Git-2.7.0-64-bit.exe"
$url = "https://github.com/git-for-windows/git/releases/download/v2.7.0.windows.1/"
$url += $file
Invoke-WebRequest -UserAgent wget -Uri $url -OutFile $file
.\Git-2.7.0-64-bit.exe /DIR=$gitdir /SILENT /COMPONENTS="icons,ext\reg\shellhere,assoc,assoc_sh" | Out-Null
rm $file
} else {
echo "git is already installed"
}
# Check for GOPATH
if (-Not (Test-Path $gopath)) {
mkdir $gopath
}
# Ensure environment variables point the way we want them to
$env:GOROOT = $gosdk
$env:GOPATH = $gopath
$env:PATH = $gosdk + "\bin;" + $mingw + "\bin;" + $env:GOPATH + "\bin;" + $gitdir + "\bin;" + $env:PATH
echo $env:PATH
echo $env:GOPATH
go version
go env
# Download delve
go get github.com/tools/godep
go get -d github.com/derekparker/delve
cd $gopath\src\github.com\derekparker\delve
godep restore
# Compile delve
mingw32-make install
cd $cwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment