This should match how you set any environment variable using Powershell (as described in this article ):
If you want it to be constant (i.e. it will be applied to any future shell):
[Environment]::SetEnvironmentVariable("GOPATH", "C:\Your\Path", "User")
One thing to note: when we used SetEnvironmentVariableto create a new user or machine level environment variable, this variable was not always displayed when this command was run in Windows PowerShell:
Get-ChildItem Env:
, , , PowerShell. ( PowerShell.)
, :
[Environment]::GetEnvironmentVariable("GOPATH","User")
, cmotley answer :
$env:GOPATH = "C:\Your\Path"
Jaykul, %UserProfile%\My Documents\WindowsPowerShell\profile.ps1 ~\.bashrc:
. " Windows PowerShell".
( 4 , , )