Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit d252483

Browse files
authored
Merge pull request #736 from darkowlzz/faq-constraint-dependencies
FAQ - pinning version of a direct dependency
2 parents ba5773d + 55f511f commit d252483

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

FAQ.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,29 @@ Here are some suggestions for when you could use `dep` or `go get`:
8585
-[@sdboyer in #376](https://github.com/golang/dep/issues/376#issuecomment-294045873)
8686

8787
## Why is `dep` ignoring a version constraint in the manifest?
88-
Only your project's directly imported dependencies are affected by a `dependencies` entry
88+
Only your project's directly imported dependencies are affected by a `constraint` entry
8989
in the manifest. Transitive dependencies are unaffected.
9090

9191
Use an `overrides` entry for transitive dependencies.
9292

93+
By default, when you specify a version without an operator, such as `~` or `=`,
94+
`dep` automatically adds a caret operator, `^`. The caret operator pins the
95+
left-most non-zero digit in the version. For example:
96+
```
97+
^1.2.3 means 1.2.3 <= X < 2.0.0
98+
^0.2.3 means 0.2.3 <= X < 0.3.0
99+
^0.0.3 means 0.0.3 <= X < 0.0.4
100+
```
101+
102+
To pin a version of direct dependency in manifest, prefix the version with `=`.
103+
For example:
104+
```
105+
[[constraint]]
106+
name = "github.com/pkg/errors"
107+
version = "=0.8.0"
108+
```
109+
110+
93111
## How do I constrain a transitive dependency's version?
94112
First, if you're wondering about this because you're trying to keep the version
95113
of the transitive dependency from changing, then you're working against `dep`'s
@@ -110,7 +128,7 @@ behave differently:
110128
* Dependencies:
111129
1. Can be declared by any project's manifest, yours or a dependency
112130
2. Apply only to direct dependencies of the project declaring the constraint
113-
3. Must not conflict with the `dependencies` declared in any other project's manifest
131+
3. Must not conflict with the `constraint` entries declared in any other project's manifest
114132
* Overrides:
115133
1. Are only utilized from the current/your project's manifest
116134
2. Apply globally, to direct and transitive dependencies

0 commit comments

Comments
 (0)