Follow


Can someone explain the relationships and purposes of GOPATH, GOROOT, GOPRIVATE, mod.go, and my $PATH?
I have a combination of these things on my mac that prevents me from running an executable after installing it :(

@dyedgrey $GOROOT is where the toolchain is installed. $GOPATH is effectively where your user cache is, typically ~/go. Generally, these should be unset and let the defaults happen. You can run `go env` to see what it knows. You should add $GOROOT/bin to your $PATH and could add $GOPATH/bin as well.

As for go.mod, this is the "new" way of developing go apps. Used to be you needed to put them under $GOPATH but you actually shouldn't do that now. I put everything under ~/src myself.

@dyedgrey See go.dev/blog/using-go-modules for more information.

Effectively, go.mod is a dependency manifest similar some other package managers' "dependencies" section e.g., npm (Node.js) or cargo (Rust). Develop these outside $GOPATH like you would with any other language. For ease of working with a group of disparate modules, read about go workspaces: go.dev/blog/get-familiar-with-

@heaths
Thanks for your advice and time, Health! I’ll do some more reading and experimenting.
I think my immediate issue was the content of the vendor directory in the repo I was working on.
I cloned the repo in a new location and everything went swimmingly.
I do appreciate your answers.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.