Documentation ¶
Overview ¶
Package genver inspires by golang.org/x/mod/semver, and processes none semantic standard version.
Index ¶
- func Compare(v, w string) int
- func Epoch(v string) string
- func InRange(v, rng string) bool
- func IsEqualRangeOnly(rng string) bool
- func IsLowerRangeOnly(rng string) bool
- func IsRelease(v string) bool
- func IsUnboundedRange(rng string) bool
- func IsUpperRangeOnly(rng string) bool
- func IsValid(v string) bool
- func Major(v string) string
- func MajorMinor(v string) string
- func RestrictUnboundedRange(w, ubrng string) (string, bool)
- type ParsedVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare returns an integer comparing two versions according to version precedence. The result will be 0 if v == w, -1 if v < w, or +1 if v > w.
func Epoch ¶
Epoch returns the epoch version without v prefix, if v is an invalid version string, Epoch returns the empty string. e.g. Epoch("v2.1.0") == "0", Epoch("1:2.1.0") == "1", Epoch("0:2.1.0") == "0".
func IsEqualRangeOnly ¶
IsEqualRangeOnly returns true if the given range has only equality range, the following cases are only equality ranges.
- "=6.3"
func IsLowerRangeOnly ¶
IsLowerRangeOnly returns true if the given range has no upper range, the following cases are only lower ranges.
- ">=0"
- ">0"
func IsUnboundedRange ¶
IsUnboundedRange returns true if the given range is unbounded, the following cases are unbounded ranges.
- ">=0"
- "<6.3"
func IsUpperRangeOnly ¶
IsUpperRangeOnly returns true if the given range has no lower range, the following cases are only upper ranges.
- "<6.3"
- "<=6.3"
func Major ¶
Major returns the major version without v prefix, if v is an invalid version string, Major returns the empty string. e.g. Major("v2.1.0") == "2", Major("1:2.1.0") == "1:2", Major("0:2.1.0") == "2".
func MajorMinor ¶
MajorMinor returns the major.minor version without v prefix, if v is an invalid version string, MajorMinor returns the empty string. e.g. MajorMinor("v2.1.0") == "2.1", MajorMinor("1:2.1.0") == "1:2.1", MajorMinor("0:2.1.0") == "2.1".
func RestrictUnboundedRange ¶
RestrictUnboundedRange returns bounded range restricted by the given boundary(w).
Types ¶
type ParsedVersion ¶
type ParsedVersion struct { Original string Epoch string Major string Minor string Patch string Rest []string Err string }
ParsedVersion holds the version information after parsed.
func Parse ¶
func Parse(v string) ParsedVersion
Parse parses the given version string into a comparable struct.
func (ParsedVersion) Compare ¶
func (pv ParsedVersion) Compare(w string) int
func (ParsedVersion) Eq ¶
func (pv ParsedVersion) Eq(w string) bool
func (ParsedVersion) Ge ¶
func (pv ParsedVersion) Ge(w string) bool
func (ParsedVersion) Gt ¶
func (pv ParsedVersion) Gt(w string) bool
func (ParsedVersion) IsZero ¶
func (pv ParsedVersion) IsZero() bool
func (ParsedVersion) Le ¶
func (pv ParsedVersion) Le(w string) bool
func (ParsedVersion) Lt ¶
func (pv ParsedVersion) Lt(w string) bool