0

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.

Jessica
  • 1,621
  • 2
  • 18
  • 34

2 Answers2

2

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.

peterSO
  • 158,998
  • 31
  • 281
  • 276
1

I think you want to run go env GOPATH instead of go env gopath. Notice the difference in capitalization. Just running go env would list all go variables.

Karthik Nayak
  • 731
  • 3
  • 14