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?
Just do
export GOPATH="/whatever/you/like/your/GOPATH/to/be"
.You can use the "export" solution just like what other guys have suggested. I'd like to provide you with another solution for permanent convenience: you can use any path as GOPATH when running Go commands.
Firstly, you need to download a small tool named
gost
: https://github.com/byte16/gost/releases . If you use ubuntu, you can download the linux version(https://github.com/byte16/gost/releases/download/v0.1.0/gost_linux_amd64.tar.gz).Then you need to run the commands below to unpack it :
You would get an executable
gost
. You can move it to/usr/local/bin
for convenient use:Run the command below to add the path you want to use as GOPATH into the pathspace
gost
maintains. It is required to give the path a name which you would use later.Run any Go command you want in the format:
For example, you want to run
go get github.com/go-sql-driver/mysql
with/home/foobar/bar
as the GOPATH, just do it as below:It would help you to set the GOPATH and run the command. But remember that you have added the path into
gost
's pathspace. If you are under any level of subdirectories of/home/foobar/bar
, you can even just run the command below which would do the same thing for short :gost
is a Simple Tool of Go which can help you to manage GOPATHs and run Go commands. For more details about how to use it to run other Go commands, you can just rungost help goCmdName
. For example you want to know more aboutinstall
, just type words below in:You can also find more details in the README of the project: https://github.com/byte16/gost/blob/master/README.md