commit | 0b32664c462de0ac3648278740882e19ef4ef857 | [log] [tgz] |
---|---|---|
author | Filippo Valsorda <filippo@cloudflare.com> | Fri Jan 08 15:13:17 2016 -0800 |
committer | Filippo Valsorda <filippo@cloudflare.com> | Fri Jan 08 15:13:17 2016 -0800 |
tree | 6f3584b946fb777f7598a3b294effa6cd7e02701 | |
parent | 0b16a9ecdc647215c80e0f3f2a40da1e010668ad [diff] |
Import upstream changes up to constabulary/gb@572f68e
gvt
is a simple Go vendoring tool made for the GO15VENDOREXPERIMENT.
It's based entirely on gb-vendor.
You run gvt fetch
when you would run go get
. gvt
downloads packages to ./vendor/...
. With GO15VENDOREXPERIMENT=1
the compiler will find and use those dependencies without import path rewriting.
gvt
works recursively as you would expect, and lets you update vendored dependencies. It also writes a manifest to ./vendor/manifest
. Finally, it strips the VCS metadata so that you can commit the vendored source cleanly.
Packages whose dependencies are vendored with gvt
are go build
-able and go get
-able by Go 1.5 with GO15VENDOREXPERIMENT=1
set. Note that projects must live within the GOPATH tree in order to be go buildable with the GO15VENDOREXPERIMENT flag.
GO15VENDOREXPERIMENT=1 go get -u github.com/FiloSottile/gvt
You know how to use go get
? That's how you use gvt fetch
.
$ gvt fetch github.com/fatih/color 2015/09/05 02:38:06 fetching recursive dependency github.com/mattn/go-isatty 2015/09/05 02:38:07 fetching recursive dependency github.com/shiena/ansicolor $ tree -d . └── vendor └── github.com ├── fatih │ └── color ├── mattn │ └── go-isatty └── shiena └── ansicolor └── ansicolor 9 directories $ cat > main.go package main import "github.com/fatih/color" func main() { color.Red("Hello, world!") } $ export GO15VENDOREXPERIMENT=1 $ go build . $ ./hello Hello, world! $ git add main.go vendor/ && git commit
Full usage on GoDoc
Some developers prefer not to check in the source of the vendored dependencies. In that case you can add lines like these to e.g. your .gitignore
vendor/** !vendor/manifest
When you check out the source again, you can then run gvt rebuild
to fetch all the dependencies at the revisions specified in the vendor/manifest
file.
Please consider that this approach has the following consequences:
go get
won't work on your packageerror: tag 'fetch' not found.
This kind of errors happens because you have an alias for gvt
pointing to git verify-tag
.
Run this, or add it to your ~/.bashrc
/ ~/.zshrc
:
unalias gvt
go build
can't find the vendored packageMake sure you set GO15VENDOREXPERIMENT=1
.
Also note that GO15VENDOREXPERIMENT does not apply when outside the GOPATH tree. That is, your project must be somewhere in a subfolder of $GOPATH
.
There are many Go vendoring tools, but they all have some subset of the following problems
go get