Skip to content
CLI command to verify versions and version constraints
Go Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
vendor
.gitignore
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
version.go
version_test.go

README.md

version

go report Release

CLI command to verify versions and version constraints. The version is build based on hashicorp/go-version.

Versions used with go-version must follow SemVer.

Install

If you are OSX user, you can use Homebrew:

$ brew tap ivan-dyachenko/version
$ brew install version

For other operating systems check releases

Basic usage

version ">=1.0, <2.0" "1.7"
go version | version ">=1.9"

Usage in the bash scripts

version -b "..." returns true|false that can be used in bash scripts

Check git version by using pipeline:

#!/bin/bash

# version supports Pipeline (Unix)
if `git version | version -b ">2.15.0"`; then
  echo "git version > 2.15.0"
else
  echo "please install git > 2.15.0"
fi

Check gcc version:

#!/bin/bash

if `version -b ">=9.0.0" "$(gcc --version)"`; then
  echo "gcc version satisfies constraints >=9.0.0"
else
  echo "gcc version doesn't satisfies constraints >=9.0.0"
fi

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.

You can’t perform that action at this time.