Setting GOPATH on Windows 10 doesn't save the value

So I’ve installed Golang in C:\Go.
I’ve checked the Path variable and there was a path to C:\Go\bin
I’ve checked the value of GOROOT variable and there was C:\Go\

I create goworkspace directory in D: (D:\goworkspace)
Inside D:\goworkspace I create three folders src, bin and pkg.
inside D:\goworkspace\src I create one more directory called github.com.
inside D:\goworkspace\src\github.com I create directory VKosev and this is where I’m going to put my projects and go files.
I open cmd and type set GOPATH=D:\goworkspace, it worked when I use go env it shows that indeed GOPATH value is D:\goworkspace.
I open git shell to use the go get tool I type go get github.com/GoesToEleven/golang-web-dev and I see this error:
package github.com/GoesToEleven/golang-web-dev: cannot download, $GOPATH not set. For more details see: go help gopath

I check go env in both Git Shell and CMD and it doesen’t show any value in GOPATH I set it again and after reopening the shell it doesen’t have value again, how do I fix this ?

Hi,
that’s not how you set an environment variable or modify the PATH permanently on Windows. your method is only valid for the opened cmd window. if you close it, your variable is forgotten.
there’s still the same ugly window that you can’t expand that was already there maybe on Windows95 to do that.
look here for example : http://www.computerhope.com/issues/ch000549.htm

but if you need to be more serious about that, look at Rapid Environment Editor. it’s really easier to use and way more effective…! (really needed tool on Windows I think).

Hi,

You need to add GOPATH as a system variable as well, just as you did for GOROOT in your screen shot.
After that you need to add %GOPATH%\bin to the Path variable (also in System Variables section in the Environment Variables dialog box)

also consider LiteIDE who has his own GOPATH management.

Thank you ! I tought I had to set it up via the CMD, my bad. Everything is working fine now.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.