What is GOPATH?

hi , my go main directory is placed in
/usr/local/go
which contains all golang main files ,
my source files are in
/home/rootx/Documents/sourceCode/go/src
i also added
:/usr/local/go/bin
to
/etc/environment
, now when i type
go env
i get
GOPATH="/home/rootx/go"
, 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

See

2 Likes

thanks for the support

2 Likes

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