Home directory?

88 views
Skip to first unread message

joseph.p...@gmail.com

unread,
Apr 23, 2023, 4:16:59 AM4/23/23
to golang-nuts
In the ‘Create a Go Module’ documentation, it keeps referencing ‘home directory’ and uses the unix command ‘cd’.

Do they literally mean my unix home directory or do they mean my GOPATH directory?

Have GOPATH and GOROOT been deprecated?

Thanks,

Hoe

Amnon

unread,
Apr 23, 2023, 4:28:41 AM4/23/23
to golang-nuts
I looked at https://go.dev/doc/tutorial/create-module 
it only has two mentions of, which are just suggestions regarding where to create your working directory.
But it is just a suggestion, and you can choose any location which is convenient for you. 

Yes GOPATH and GOROOT have been deprecated. Any tutorials which tell you to put your code under $GOPATH are ancient history
and should be ignored. 

Jan Mercl

unread,
Apr 23, 2023, 4:49:40 AM4/23/23
to Amnon, golang-nuts
On Sun, Apr 23, 2023 at 10:28 AM Amnon <amn...@gmail.com> wrote:

> Yes GOPATH and GOROOT have been deprecated.

Both are alive and well. They are essential for the build system/go
command to work as required.

tl;dr: There's a default value of GOPATH so one does not have to set
it. A much longer version can be obtained by '$ go help gopath'.

Amnon

unread,
Apr 23, 2023, 4:56:02 AM4/23/23
to golang-nuts
Ok Jan, you are right. They do still play a part under the hood.
So external modules get cached under $GOMODCACHE which is $GOPATH/pkg/mod by default
and go install installs executables under $GOBIN which is $GOPATH/bin by default.

But my point is that (apart from $GOBIN), this is something that the end-user no longer needs to bother themselves with.
Unlike the earliest go versions, you no longer need to set GOPATH in order to compile your code.
And you no longer need to insert your code into a directory tree under GOPATH. 
Reply all
Reply to author
Forward
0 new messages