I want to install json2csv using go get github.com/jehiah/json2csv
but I receive this error:
package github.com/jehiah/json2csv: cannot download, $GOPATH not set. For more details see: go help go path
Any help on how to fix this on MacOS?
I want to install json2csv using go get github.com/jehiah/json2csv
but I receive this error:
package github.com/jehiah/json2csv: cannot download, $GOPATH not set. For more details see: go help go path
Any help on how to fix this on MacOS?
I found easier to do it like this:
Your
$GOROOT
should not be set up. You$GOPATH
should be set to$HOME/go
by typingexport $GOPATH=$HOME/go
Please type
export GOROOT=""
to fix your problem.For MAC this worked well for me.
and add the below at the end of the file
This should fix the problem. Try opening a new terminal and echo $GOPATH you should see the correct value.
I had to run an application as root (to open a webserver on port 80), this produced the error for me, because the sudo user has a different environment than the normal user, hence GOPATH was not set.
If someone else is having this problem, add
-E
to the command, this will preserve the user environment.sudo -E go run main.go
For more infos see discussion here: Google Groups – GOPATH Problem
This one worked
Setting up Go development environment on Ubuntu, and how to fix $GOPATH / $GOROOT
Steps
Set $GOPATH in .bashrc,
Using brew
I installed it using
brew
.When it was done if you run this brew command it'll show the following info:
The important pieces there are these lines:
Setting up GO's environment
That shows where GO was installed. We need to do the following to setup GO's environment:
You can then check using GO to see if it's configured properly:
Setting up json2csv
Looks good, so lets install
json2csv
:What just happened? It installed it. You can check like this:
OK, so why can't I type
json2csv
in my shell? That's because the/bin
directory under$GOPATH
isn't on your$PATH
.So let's temporarily add it:
And re-check:
Now it's there:
Add the modifications we've made to
$PATH
and$GOPATH
to your$HOME/.bash_profile
to make them persist between reboots.