What is GOPATH?


hi , my go main directory is placed in
which contains all golang main files ,
my source files are in
i also added
, now when i type
go env
i get
, and there is no /go file in this path , so how can i change it ? and what is GOPATH ?

thank you for your support

(Norbert Melzer) #2

The GOPATH is the root of your go workspace.

It defaults to ~/go, but you can set the environment variable GOPATH to override the default.

How to set an environment variable depends on your operating system.

It looks as if you were using linux, so it should usually be enough to have export GOPATH=… in your shells RC file.

You usually do not want to set this system wide, but only for the current user, so /etc/environment is not a good place.

(Lutz Horn) #3



thanks for the support

(Eric Lindblad) #5

Can I set multiple $GOPATH? (Go Forum / Oct 3, 2019)

wiki: SettingGOPATH (redesign) #34967 (Issues / Oct 19, 2019)