GOPATH and GOROOT
Posted on August 16, 2021 (Last modified on July 11, 2024) • 1 min read • 119 wordsgo
has some unique concepts, one of them is a system-wide (user-wide) central go
directory where things “happen” (e.g. modules being downloaded, etc.). For example, if you perform hugo mod get
you essentially perform go mod get
, which then downloads required modules … into your $GOPATH
. Or $GOROOT/something
, I really don’t quite get it, and I don’t care unless it stops working. Which it did.
You often read “Just look into $GOPATH and see if it’s there”. Unfortunately I never set the value so there is no environment variable. The default of $HOME/go
does not exist on my mac. Now what?
Thanks to 0x434d53 I now know to do this, which prints the values used by go
:
go env