How to change GOPATH in powershell

I am trying to add a project directory in GOPATH, in linux I can do

export GOPATH=$HOME/mygo in ~ / .bashrc

what is equivalence in powershell

+5
source share
2 answers

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 , , )

+8

:

$env:GOPATH = "$HOME\mygo"

+4

All Articles