Command govend helps build packages reproducibly by fixing their dependencies.
This tool assumes you are working in a standard Go workspace, as described in http://golang.org/doc/code.html. We require Go 1.5 or newer to build govend itself, and you can only use it with go 1.5 and newer.
NOTE: This is currently very alpha. I wrote it at GopherCon and haven't used it very much yet.
$ go get github.com/azylman/govend
How to add govend in a new project.
Assuming you've got everything working already (i.e. you can
build your project with go install
and test it with go test
),
it's one command to start using:
$ govend
This will save a list of dependencies to the file vendor/Deps.json, and copy their source code into vendor/. Read over its contents and make sure it looks reasonable. Then commit the whole vendor directory to version control.
To add a new package foo/bar, do this:
- Edit your code to import foo/bar.
- Run
govend
.
To update a package, do this:
- Run
govend -u foo/bar
.
You can use the ...
wildcard, for example govend -u foo/...
.
You can also use ./...
to update everything, govend -u ./...
.
This is the default if no arguments are provided.
Deps is a json file with the following structure:
type Deps struct {
ImportPath string
GoVersion string // Abridged output of 'go version'.
Deps []struct {
ImportPath string
Comment string // Description of commit, if present.
Rev string // VCS-specific commit ID.
}
}
Example Deps:
{
"ImportPath": "github.com/kr/hk",
"GoVersion": "go1.1.2",
"Deps": [
{
"ImportPath": "code.google.com/p/go-netrc/netrc",
"Rev": "28676070ab99"
},
{
"ImportPath": "github.com/kr/binarydist",
"Rev": "3380ade90f8b0dfa3e363fd7d7e941fa857d0d13"
}
]
}
Heavily inspired by godep. The subpackages in this repository are made from godep code, refactored into a package.