macosgoinstallationgopath

GOPATH not being automatically set?


I'm installing Golang on my MacBook.

According to multiple sources (example), Golang 1.8 and onwards automatically sets GOPATH.

If I run the command go env gopath in Terminal, nothing is returned. Does this mean the GOPATH variable is not set?

I have attempted to set it manually with export GOPATH=$HOME/go (as per this example).

Yet this still returns nothing.

I have tried reinstalling Golang. This works on my Windows machine, just not MacOS.


Solution

  • Go will use a default for GOPATH. Run the go env command to see the value.

    Run the go env GOPATH command for just the GOPATH value.