DockerCLI/vendor/github.com/hashicorp/go-version
Sebastiaan van Stijn 87cf5b606a
bump hashicorp/go-version v1.2.0
full diff: 23480c0665...v1.2.0

includes:

- hashicorp/go-version#53 Implement GreaterThanOrEqual + LessThanOrEqual
- hashicorp/go-version#45 Add new constructor that strictly adheres to semver specs
- hashicorp/go-version#40 Support Original to return original version
    - fixes hashicorp/go-version#16 Store and allow retrieval of the string of the version in its original form
    - fixes hashicorp/go-version#27 Support for zero padded numbers (e.g. `17.03.0-ce`)
- hashicorp/go-version#41 Segments64 makes a copy to match Segments
- hashicorp/go-version#38 When using a specific pattern, unintended results are returned

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-24 13:21:28 +02:00
..
LICENSE Vendoring bump for containerd and licensing 2018-08-20 09:42:05 -07:00
README.md Vendoring bump for containerd and licensing 2018-08-20 09:42:05 -07:00
constraint.go Vendoring bump for containerd and licensing 2018-08-20 09:42:05 -07:00
go.mod bump hashicorp/go-version v1.2.0 2019-10-24 13:21:28 +02:00
version.go bump hashicorp/go-version v1.2.0 2019-10-24 13:21:28 +02:00
version_collection.go Vendoring bump for containerd and licensing 2018-08-20 09:42:05 -07:00

README.md

Versioning Library for Go

Build Status

go-version is a library for parsing versions and version constraints, and verifying versions against a set of constraints. go-version can sort a collection of versions properly, handles prerelease/beta versions, can increment versions, etc.

Versions used with go-version must follow SemVer.

Installation and Usage

Package documentation can be found on GoDoc.

Installation can be done with a normal go get:

$ go get github.com/hashicorp/go-version

Version Parsing and Comparison

v1, err := version.NewVersion("1.2")
v2, err := version.NewVersion("1.5+metadata")

// Comparison example. There is also GreaterThan, Equal, and just
// a simple Compare that returns an int allowing easy >=, <=, etc.
if v1.LessThan(v2) {
    fmt.Printf("%s is less than %s", v1, v2)
}

Version Constraints

v1, err := version.NewVersion("1.2")

// Constraints example.
constraints, err := version.NewConstraint(">= 1.0, < 1.4")
if constraints.Check(v1) {
	fmt.Printf("%s satisfies constraints %s", v1, constraints)
}

Version Sorting

versionsRaw := []string{"1.1", "0.7.1", "1.4-beta", "1.4", "2"}
versions := make([]*version.Version, len(versionsRaw))
for i, raw := range versionsRaw {
    v, _ := version.NewVersion(raw)
    versions[i] = v
}

// After this, the versions are properly sorted
sort.Sort(version.Collection(versions))

Issues and Contributing

If you find an issue with this library, please report an issue. If you'd like, we welcome any contributions. Fork this library and submit a pull request.