You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
Dep is a prototype dependency management tool. It requires Go 1.7 or newer to compile.
11
+
`dep` is a prototype dependency management tool for Go. It requires Go 1.7 or newer to compile.
6
12
7
-
`dep` is NOT an official tool. Yet. Check out the [Roadmap](https://github.com/golang/dep/wiki/Roadmap)!
13
+
`dep` is the official _experiment_, but not yet the official tool. Check out the [Roadmap](https://github.com/golang/dep/wiki/Roadmap) for more on what this means!
8
14
9
15
## Current status
10
16
11
17
`dep` is safe for production use. That means two things:
12
18
13
19
* Any valid metadata file (`Gopkg.toml` and `Gopkg.lock`) will be readable and considered valid by any future version of `dep`.
20
+
* The CLI UI is mostly stable. `dep init` and `dep ensure` are mostly set; `dep status` is likely to change a fair bit, and `dep prune` is [going to be absorbed into `dep ensure`](https://github.com/golang/dep/issues/944).
14
21
* Generally speaking, it has comparable or fewer bugs than other tools out there.
15
22
16
23
That said, keep in mind the following:
17
24
18
25
*`dep` is still changing rapidly. If you need stability (e.g. for CI), it's best to rely on a released version, not tip.
19
-
*[Some changes](https://github.com/golang/dep/pull/489) are pending to the CLI interface. Scripting on dep before they land is unwise.
20
26
*`dep`'s exported API interface will continue to change in unpredictable, backwards-incompatible ways until we tag a v1.0.0 release.
21
27
22
28
## Context
@@ -44,7 +50,7 @@ $ brew install dep
44
50
$ brew upgrade dep
45
51
```
46
52
47
-
To start managing dependencies using dep, run the following from your project root directory:
53
+
To start managing dependencies using dep, run the following from your project's root directory:
48
54
49
55
```sh
50
56
$ dep init
@@ -63,10 +69,15 @@ This does the following:
63
69
64
70
## Usage
65
71
66
-
There is one main subcommand you will use: `dep ensure`. `ensure` first makes
67
-
sure `Gopkg.lock` is consistent with your `import`s and `Gopkg.toml`. If any
68
-
changes are detected, it then populates `vendor/` with exactly what's described
69
-
in `Gopkg.lock`.
72
+
There is one main subcommand you will use: `dep ensure`. `ensure` first checks that `Gopkg.lock` is consistent with `Gopkg.toml` and the `import`s in your code. If any
73
+
changes are detected, `dep`'s solver works out a new `Gopkg.lock`. Then, `dep` checks if the contents of `vendor/` are what `Gopkg.lock` (the new one if applicable, else the existing one) says it should be, and rewrites `vendor/` as needed to bring it into line.
74
+
75
+
In essence, `dep ensure`[works in two phases to keep four buckets of state in sync](https://youtu.be/5LtMb090AZI?t=20m4s):
_Note: until we ship [vendor verification](https://github.com/golang/dep/issues/121), we can't efficiently perform the `Gopkg.lock` <-> `vendor/` comparison, so `dep ensure` unconditionally regenerates all of `vendor/` to be safe._
70
81
71
82
`dep ensure` is safe to run early and often. See the help text for more detailed
72
83
usage instructions.
@@ -91,12 +102,13 @@ matches the constraints from the manifest. If the dependency is missing from
91
102
92
103
### Adding a dependency
93
104
94
-
1.`import` the package in your `*.go` source code file(s).
95
-
1. Run the following command to update your `Gopkg.lock` and populate `vendor/` with the new dependency.
105
+
```sh
106
+
$ dep ensure -add github.com/foo/bar
107
+
```
96
108
97
-
```sh
98
-
$ dep ensure
99
-
```
109
+
This adds a version constraint to your `Gopkg.toml`, and updates `Gopkg.lock` and `vendor/`. Now, import and use the package in your code! ✨
110
+
111
+
`dep ensure -add` has some subtle behavior variations depending on the project or package named, and the state of your tree. See `dep ensure -examples` for more information.
On top of that, if you have added new imports to your project or modified the manifest file without running `dep ensure` again, `dep status` will tell you there is a mismatch between the lock file and the current status of the project.
141
+
On top of that, if you have added new imports to your project or modified `Gopkg.toml`without running `dep ensure` again, `dep status` will tell you there is a mismatch between `Gopkg.lock` and the current status of the project.
130
142
131
143
```sh
132
144
$ dep status
@@ -142,23 +154,33 @@ As `dep status` suggests, run `dep ensure` to update your lockfile. Then run `de
142
154
143
155
### Updating dependencies
144
156
145
-
(to the latest version allowed by the manifest)
157
+
Updating brings the version of a dependency in`Gopkg.lock` and `vendor/` to the latest version allowed by the constraints in`Gopkg.toml`.
158
+
159
+
You can update just a targeted subset of dependencies (recommended):
160
+
161
+
```sh
162
+
$ dep ensure -update github.com/some/project github.com/other/project
163
+
$ dep ensure -update github.com/another/project
164
+
```
165
+
166
+
Or you can update all your dependencies at once:
146
167
147
168
```sh
148
169
$ dep ensure -update
149
170
```
150
171
172
+
"Latest" means different things depending on the type of constraint in use. If you're depending on a `branch`, `dep` will update to the latest tip of that branch. If you're depending on a `version` using [a semver range](#semantic-versioning), it will update to the latest version in that range.
173
+
151
174
### Removing dependencies
152
175
153
176
1. Remove the `import`s and all usage from your code.
177
+
1. Remove `[[constraint]]` rules from `Gopkg.toml` (if any).
154
178
1. Run
155
179
156
180
```sh
157
181
$ dep ensure
158
182
```
159
183
160
-
1. Remove from `Gopkg.toml`, if it was in there.
161
-
162
184
### Testing changes to a dependency
163
185
164
186
Making changes in your `vendor/` directory directly is not recommended, as dep
0 commit comments