A very small shell script that fetches Go packages pinned to your preferred version.
For creating consistent and repeatable builds.
To install specific git revisions of Go packages into your GOPATH
:
$ cat Gofile
github.com/lib/pq 8910d1c3a4bda5c97c50bc38543953f1f1e1f8bb
github.com/julienschmidt/httprouter b59a38004596b696aca7aa2adccfa68760864d86
github.com/hashicorp/golang-lru d85392d6bc30546d352f52f2632814cde4201d44
bitbucket.org/cranej/go-mvc 7:65b80632192a
bitbucket.org/binet/go-ctypes 4:0344428b46d0
launchpad.net/mgo 1
$ go-getter Gofile
Uhh that's it.
If you program Go you are no doubt familiar with its
package manager go get
.
Like everything about Go, it's fantastically opinionated: you depend on the HEAD version of a package and it's the package author's responsibility to ensure HEAD always contains a good version and maintains backwards compatibility.
In a perfect world, that's great. Except it's not always the case. Libraries evolve, behaviors change, APIs evolve, regressions come and go, performance fluctuates, bad things sometimes appear in HEAD, even if only for a short period of time.
go-getter
is an alternative to go get
that has a stronger opinion: Given
an identical source tree, building a project tomorrow should give you the same
result as building it today, and yesterday, and in 2 years time.
Because it sucks when you need to cut an emergency release and the code no longer compiles due to something out of your control.
Grab go-getter. It's a very small shell script. Don't forget to chmod +x
.
Create a file to declare your package dependencies and git/svn/hg/bzr hash versions.
I call my file Gofile
but you can call it anything.
# List packages and git hashes of versions you want
github.com/lib/pq 8910d1c3a4bda5c97c50bc38543953f1f1e1f8bb
github.com/julienschmidt/httprouter b59a38004596b696aca7aa2adccfa68760864d86
github.com/hashicorp/golang-lru d85392d6bc30546d352f52f2632814cde4201d44
bitbucket.org/cranej/go-mvc 7:65b80632192a
bitbucket.org/binet/go-ctypes 4:0344428b46d0
launchpad.net/mgo 1
Then run:
$ go-getter Gofile
This will ensure that your packages are installed in the correct place in your
GOPATH
. You can run it repeatedly and it will ensure packages are always at
your desired version.
We both have opinions. They're both right. I can't choose for you.
Yep, I tried a few. Some of them were written in Go, which lead to a bootstrapping issue (you had to go get them, but which version were you getting?). Others were too complicated or confusing for me. I just want to download dependencies.
Me too. That's why I did.
It doesn't. By design. If you depend libraries that depend on other libraries, you must explicitly list them, that way you can state the versions of those libraries too.
View the latest commit on GitHub. You'll see it there.
Probably not. Your best bet is to fork it and publicize your better version.
No. It's a teeny tiny shell script. Just check it in to your project and run it from there.
That basically means taking a snapshot of the code and including it in your own repository. Yes, it's even better as you are isolated from remote repositories being deleted. But it's also annoying because you have to check all the code into your own repo. This is a pragmatic middle ground that gives you most of the advantages of vendoring, without repository bloat.
You don't. It's for top-level (main) programs only.
Use different GOPATH
s. I typically have one GOPATH per main project.
Initially @joewalnes. Then @sriniprash made it work properly.
I love gophers too.