3
Command godep helps build packages reproducibly by fixing their dependencies.
5
This tool assumes you are working in a standard Go workspace,
6
as described in http://golang.org/doc/code.html. We require Go 1.1
7
or newer to build godep itself, but you can use it on any project
8
that works with Go 1 or newer.
12
$ go get github.com/kr/godep
16
How to add godep in a new project.
18
Assuming you've got everything working already, so you can
19
build your project with `go install` and test it with `go test`,
20
it's one command to start using:
24
This will save a list of dependencies to the file Godeps/Godeps.json,
25
and copy their source code into Godeps/_workspace.
26
Read over its contents and make sure it looks reasonable.
27
Then commit the file to version control.
29
You can omit the source code with the flag -copy=false.
30
This means fewer files to store in your local repository, but
31
subsequent invocations of `godep go` will need to access the
32
network to fetch the appropriate source code later. Using the
33
default behavior is faster and more reliable.
38
2. Run `godep go test`
41
#### Add or Update a Dependency
43
To add or update package foo/bar, do this:
45
1. Run `godep restore`
46
2. Run `go get -u foo/bar`
47
3. Edit your code, if necessary, to import foo/bar.
50
Before committing the change, you'll probably want to inspect
51
the changes to Godeps, for example with `git diff`,
52
and make sure it looks reasonable.
54
#### Multiple Packages
56
If your repository has more than one package, you're probably
57
accustomed to running commands like `go test ./...`,
58
`go install ./...`, and `go fmt ./...`.
59
Similarly, you should run `godep save ./...` to capture the
60
dependencies of all packages.
62
#### Using Other Tools
64
The `godep path` command helps integrate with commands other
65
than the standard go tool. This works with any tool that reads
66
GOPATH from its environment, for example the recently-released
67
[oracle command](http://godoc.org/code.google.com/p/go.tools/cmd/oracle).
69
$ GOPATH=`godep path`:$GOPATH
70
$ oracle -mode=implements .
74
Godeps is a json file with the following structure:
79
GoVersion string // Abridged output of 'go version'.
80
Packages []string // Arguments to godep save, if any.
83
Comment string // Description of commit, if present.
84
Rev string // VCS-specific commit ID.
93
"ImportPath": "github.com/kr/hk",
94
"GoVersion": "go1.1.2",
97
"ImportPath": "code.google.com/p/go-netrc/netrc",
101
"ImportPath": "github.com/kr/binarydist",
102
"Rev": "3380ade90f8b0dfa3e363fd7d7e941fa857d0d13"