This application restores the go get -d functionality for modern Go. If you're looking for a helper tool to organize Go projects under ${GOPATH}, this is for you!
The classic go get -d used to clone the import repository and build the application right away, placing the executable in the ${GOPATH}/bin directory. Nowadays, you would use go install if the goal is only to install the application executable.
Therefore, go-get-d is most useful for a developer to quickly get started with a Go repository, using the "classic" ${GOPATH} organization style.
Use go install as the following example:
go install github.com/otaviof/go-get-d@latestWhen working on this repository you can alternatively use the install target, i.e.:
make installThe executable is placed on ${GOPATH}/bin.
The usage is straightforward, the only input required is the import name. For instance:
go-get-d github.com/otaviof/go-get-dA practical way to clone the import repository and enter the directory, is using a shell function. The function will call go-get-d with the --path flag and change the directory for you.
Add the go_get_d function to your .bashrc or .zshrc file, alternatively, you can source the gogetd.sh.
After including the function, or sourcing the file, you can use it like this:
go_get_d github.com/otaviof/go-get-dThe shell function will change into project's directory:
$ go_get_d github.com/otaviof/go-get-d
$ pwd
/home/otaviof/go/src/github.com/otaviof/go-get-d
You can also use the eval command to execute the cd directly in your shell:
eval $(go-get-d github.com/otaviof/go-get-d)You can additionally inspect the given import searching for the main package, when found it will be subject to go build, creating the application executable. Please consider the usage of the --inspect flag:
go-get-d --inspect github.com/otaviof/go-get-dThe --inspect flags makes it act as go install, therefore the application executable is stored on the ${GOPATH}/bin.