Jessica
Jessica

Reputation: 2051

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.

Upvotes: 0

Views: 1425

Answers (2)

peterSO
peterSO

Reputation: 166539

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.

Upvotes: 2

Karthik Nayak
Karthik Nayak

Reputation: 740

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.

Upvotes: 1

Related Questions