Skip to content

Instantly share code, notes, and snippets.

@joerocklin
Last active January 11, 2016 21:04
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 joerocklin/1b5e21588b6bfed001b6 to your computer and use it in GitHub Desktop.
Save joerocklin/1b5e21588b6bfed001b6 to your computer and use it in GitHub Desktop.
Setup the current working directory as your GOPATH
# Set the GOPATH directory for this user
Write-Output "Setting $pwd as GOPATH user environment variable"
[Environment]::SetEnvironmentVariable("GOPATH",$pwd,"User")
$Env:GOPATH = $pwd
# Update the user's PATH to include the bin directory underneath GOPATH
$goBinPath = Join-Path $pwd 'bin'
if ($([Environment]::GetEnvironmentVariable("Path","User")).ToLower().Contains($($goBinPath).ToLower()) -eq $false ) {
Write-Output "Adding $goBinPath to User Path"
[Environment]::SetEnvironmentVariable("Path","$goBinPath;$Env:Path","User")
$Env:Path = "$goBinPath;$Env:Path"
} else {
Write-Output "$pwd is already part of your path"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment