I've been given instructions to run go get <some-remote-git-repo>
which seems to succeed, but it's not clear to me where the package was installed to so I can run an executable from it.
Per https://golang.org/doc/code.html#remote it seems it will be installed in $GOPATH/bin
but $GOPATH
isn't defined in my shell (though the go get
command seems to work fine). Go is installed via Homebrew.
Best Answer
I found the missing clue by running brew info go
, which says:
==> CaveatsA valid GOPATH is required to use the `go get` command.If $GOPATH is not specified, $HOME/go will be used by default:https://golang.org/doc/code.html#GOPATH
From that I found the executable in question at $HOME/go/bin
.
go env
you can get the path from GOMODCACHE
Even if you don't have a $GOPATH variable you can see what it uses by doing go env GOPATH
.
Try this to see what your path is:
echo `go env GOPATH`/bin
I had a similar problem which is why I found your question. However, in my case I did not have an empty GOPATH but one with multiple directories. I worked out the issue and describe it here...
If you run go get and you already have the package it says nothing (even with the -v option). This is confusing if it's not in the first directory of your GOPATH. Ie you run go get , there is no error or any message but when you check the first directory of the GOPATH (which is where the doc says it should be) you can't find it.
I eventually found it, but since I have a large GOPATH this was rather tedious.
Using go build
Try this with main.go
. In your greeter directory, run the following command:
go build
In this case, you built your greeter application into an executable file that was added to your current directory. Check this by running the ls command:
ls./greeter