I can specify dependencies to be downloaded by go get
after checking out my project by importing them. I can even force the download of packages that are not used in the code by importing them for side effects:
import _ "github.com/jteeuwen/go-bindata"
Furthermore, on the shell I can apparently install a program with go get
by using an ellipsis after the path:
$ go get github.com/jteeuwen/go-bindata/...
However, it seems I cannot combine both techniques:
import _ "github.com/jteeuwen/go-bindata/..."
$ go get
main.go:9:8: open c:\gopath\src\github.com\jteeuwen\go-bindata\...: Access denied
I would like to tell go get
that for building (actually go generate
ing) this project, go-bindata
has to be installed. Is it possible to specify install-dependencies?
In one of my projects I use Godep. According to its page:
This tool assumes you are working in a standard Go workspace, as described in http://golang.org/doc/code.html. We expect godep to build on Go 1.4* or newer, but you can use it on any project that works with Go 1 or newer.
You'll have your dependencies in a JSON file, just like Node, Bower, etc... It's vert simple to use.
In your case, assuming you already have go get
ed the package, run:
godep save
This will generate the JSON file with all your other dependencies and save to a folder in your project. Thanks to it I was capable of cross compiling my project.
To answer your question: No.
But you could vendor go-bindata into your project which would make it available after after go get
ing your project.
But maybe there is a slight confusion about when and why to run go generate
: The intended use for go generate
(as I understand it) is for package or command authors to generate code during the development phase. Code which is checked in and processed "normally" by go {build,install,get}
. So you run go generate
, check in the generated stuff and users of your package go get
it and do not run go generate. They don't need to, the code comes in the proper checked in version during get
ing.
For more complicated builds which a end-user has to perform: Use Makefiles or similar tools as such stuff is out of the scope of go get
.