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

Commit 911cd22

Browse files
authored
Merge pull request #809 from darkowlzz/version-doc
docs: Gopkg.toml.md version
2 parents a1db233 + e212ae6 commit 911cd22

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

FAQ.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ Here are some suggestions for when you could use `dep` or `go get`:
8383
* Use `required` to explicitly add a dependency that is not imported directly or transitively, for example a development package used for code generation.
8484
* Use `ignored` to ignore a package and any of that package's unique dependencies.
8585

86+
Refer [Gopkg.toml](https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md)
87+
for detailed definitions of the above terms.
88+
8689
## How do I constrain a transitive dependency's version?
8790
First, if you're wondering about this because you're trying to keep the version
8891
of the transitive dependency from changing, then you're working against `dep`'s
@@ -171,20 +174,8 @@ Only your project's directly imported dependencies are affected by a `constraint
171174
in the manifest. Transitive dependencies are unaffected.
172175

173176
Use an `override` entry for transitive dependencies.
174-
175-
By default, when you specify a version without an operator, such as `~` or `=`,
176-
`dep` automatically adds a caret operator, `^`. The caret operator pins the
177-
left-most non-zero digit in the version. For example:
178-
```
179-
^1.2.3 means 1.2.3 <= X < 2.0.0
180-
^0.2.3 means 0.2.3 <= X < 0.3.0
181-
^0.0.3 means 0.0.3 <= X < 0.1.0
182-
```
183-
184-
To pin a version of direct dependency in manifest, prefix the version with `=`.
185-
For example:
186177
```
187-
[[constraint]]
178+
[[override]]
188179
name = "github.com/pkg/errors"
189180
version = "=0.8.0"
190181
```

docs/Gopkg.toml.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,33 @@ An `override` has the same structure as a `constraint` declaration, but supersed
7171
system2-data = "value that is used by another system"
7272
```
7373

74+
## `version`
75+
76+
`version` is a property of `constraint`s and `override`s. It is used to specify
77+
version constraint of a specific dependency.
78+
79+
Internally, dep uses [Masterminds/semver](https://github.com/Masterminds/semver)
80+
to work with semver versioning.
81+
82+
`~` and `=` operators can be used with the versions. When a version is specified
83+
without any operator, `dep` automatically adds a caret operator, `^`. The caret
84+
operator pins the left-most non-zero digit in the version. For example:
85+
```
86+
^1.2.3 means 1.2.3 <= X < 2.0.0
87+
^0.2.3 means 0.2.3 <= X < 0.3.0
88+
^0.0.3 means 0.0.3 <= X < 0.1.0
89+
```
90+
91+
To pin a version of direct dependency in manifest, prefix the version with `=`.
92+
For example:
93+
```
94+
[[constraint]]
95+
name = "github.com/pkg/errors"
96+
version = "=0.8.0"
97+
```
98+
99+
[Why is dep ignoring a version constraint in the manifest?](https://github.com/golang/dep/blob/master/FAQ.md#why-is-dep-ignoring-a-version-constraint-in-the-manifest)
100+
74101
# Example
75102

76103
Here's an example of a sample Gopkg.toml with most of the elements
@@ -102,4 +129,4 @@ codename = "foo"
102129

103130
[metadata]
104131
propertyX = "valueX"
105-
```
132+
```

0 commit comments

Comments
 (0)