I've created an API in Go in which I've installed two packages via go get
and have created four others for my own use. Everything seems to work fine. However I would like to move where the packages are so that I can have everything within my Git directory.
From what I've read, it should be as easy as changing my GOPATH
variable to the new directory, and running go get
again to test. Is this correct? If it is, am I doing anything wrong? Below is what shows in the terminal (Mac OS X) when I run go env
. If any other info would be useful, please let me know. Thanks.
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Applications/MAMP/htdocs/git/cbi/api"
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CGO_ENABLED="1"
I should clarify that by default my GOPATH
was an empty string. I tried updating it to the directory above since that is where I wish new packages be installed, and also for Go to look for any packages I've created an placed there.
I'm setting my GOPATH
variable by running:
export GOPATH="/Applications/MAMP/htdocs/git/cbi/api"
After doing this, I can see the variable has been set when I type go env
. However if I quit Terminal and then open it back up, and run go env
again, the GOPATH
variable is not set. Is there a reason it's not saving? Should I be setting it another way instead of export?