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

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.

1 Like



thanks for the support


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