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

docs: Gopkg.toml.md version #809

Merged
merged 2 commits into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Here are some suggestions for when you could use `dep` or `go get`:
* Use `required` to explicitly add a dependency that is not imported directly or transitively, for example a development package used for code generation.
* Use `ignored` to ignore a package and any of that package's unique dependencies.

Refer [Gopkg.toml](https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md)
for detailed definitions of the above terms.

## How do I constrain a transitive dependency's version?
First, if you're wondering about this because you're trying to keep the version
of the transitive dependency from changing, then you're working against `dep`'s
Expand Down Expand Up @@ -171,20 +174,8 @@ Only your project's directly imported dependencies are affected by a `constraint
in the manifest. Transitive dependencies are unaffected.

Use an `override` entry for transitive dependencies.

By default, when you specify a version without an operator, such as `~` or `=`,
`dep` automatically adds a caret operator, `^`. The caret operator pins the
left-most non-zero digit in the version. For example:
```
^1.2.3 means 1.2.3 <= X < 2.0.0
^0.2.3 means 0.2.3 <= X < 0.3.0
^0.0.3 means 0.0.3 <= X < 0.1.0
```

To pin a version of direct dependency in manifest, prefix the version with `=`.
For example:
```
[[constraint]]
[[override]]
name = "github.com/pkg/errors"
version = "=0.8.0"
```
Expand Down
29 changes: 28 additions & 1 deletion docs/Gopkg.toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,33 @@ An `override` has the same structure as a `constraint` declaration, but supersed
system2-data = "value that is used by another system"
```

## `version`

`version` is a property of `constraint`s and `override`s. It is used to specify
version constraint of a specific dependency.

Internally, dep uses [Masterminds/semver](https://github.com/Masterminds/semver)
to work with semver versioning.

`~` and `=` operators can be used with the versions. When a version is specified
without any operator, `dep` automatically adds a caret operator, `^`. The caret
operator pins the left-most non-zero digit in the version. For example:
```
^1.2.3 means 1.2.3 <= X < 2.0.0
^0.2.3 means 0.2.3 <= X < 0.3.0
^0.0.3 means 0.0.3 <= X < 0.1.0
```

To pin a version of direct dependency in manifest, prefix the version with `=`.
For example:
```
[[constraint]]
name = "github.com/pkg/errors"
version = "=0.8.0"
```

[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)

# Example

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

[metadata]
propertyX = "valueX"
```
```