# README
SemVer
https://github.com/Masterminds/semver, but support any numbers version part.
Install and Use
go get github.com/ImSingee/semver
See documents
Version Compare & Constraint Rules
Help me translate into English, wrap it in a pre block in markdown format for me; this is a Github Readme
Supported constraint syntax
Basic comparison
=
or no symbol!=
>
>=
<
<=
Logical operations
- AND: Multiple matching conditions can be separated by
,
Range
V1 - V2
is equivalent to>= V1, <= V2
Wildcard
- A single
*
matches any version number 1.2.x
is equivalent to>=1.2, <1.3
Minor version
~1.2.3.4
is equivalent to>= 1.2.3.4, < 1.2.4
~1.2.3
is equivalent to>= 1.2.3, < 1.3
- Special
~1.2
is equivalent to>= 1.2, < 1.3
- Special
~1
is equivalent to>= 1, < 2
Major version
^1.2.3
is equivalent to>= 1.2.3, < 2
^1.2
is equivalent to>= 1.2, < 2
^1
is equivalent to>= 1, < 2
Matching different number of digits
Compare by padding 0 to the maximum significant digit
According to this rule, there are 1.1
== 1.1.0
== 1.1.0.0
Matching with pre-release version numbers
When excluding the same pre-release version numbers, the pre-release version number match will be performed
- One has a pre-release version number, the other does not: the one without is larger
1.0-hello
<1.0
- Both have pre-release version numbers: perform pre-release version number ASCII comparison, which will be grouped by
.
and numeric groups will be matched numerically1.0-alpha
<1.0-beta
1.0-alpha10
<1.0-alpha2
1.0-alpha.2
<1.0-alpha.10
1.0-alpha.100
<1.0-beta
Metadata information
Only when =
is matched and the constraint contains metadata will the metadata be checked, otherwise the metadata will be ignored
=1.0.0+hello
can only match1.0.0+hello
but not1.0.0
(however, it can match1.0+hello
1+hello
)=1.0.0
can match1.0.0
1.0.0+anything
>1.0.0
can match1.0.1
1.0.1+anything
>1.0.0+hello
is invalid
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
MustParse parses a given version and panics on error.
NewConstraint returns a Constraints instance that a Version instance can be checked against.
NewVersion parses a given version and returns an instance of Version or an error if unable to parse the version.
No description provided by the author
StrictNewVersion parses a given version and returns an instance of Version or an error if unable to parse the version.
# Variables
ErrEmptyString is returned when an empty string is passed in for parsing.
ErrInvalidCharacters is returned when invalid characters are found as part of a version.
ErrInvalidMetadata is returned when the metadata is an invalid format.
ErrInvalidPrerelease is returned when the pre-release is an invalid format.
ErrInvalidSemVer is returned a version is found to be invalid when being parsed.
ErrSegmentStartsZero is returned when a version segment starts with 0.
# Structs
Constraints is one or more constraint that a semantic version can be checked against.
Version represents a single semantic version.
# Type aliases
Collection is a collection of Version instances and implements the sort interface.