genver

package
v0.0.0-...-de1fd8b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package genver inspires by golang.org/x/mod/semver, and processes none semantic standard version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(v, w string) int

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

func Epoch(v string) string

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 InRange

func InRange(v, rng string) bool

InRange returns true if the given version is in the given range. nolint:cyclop

func IsEqualRangeOnly

func IsEqualRangeOnly(rng string) bool

IsEqualRangeOnly returns true if the given range has only equality range, the following cases are only equality ranges.

  • "=6.3"

func IsLowerRangeOnly

func IsLowerRangeOnly(rng string) bool

IsLowerRangeOnly returns true if the given range has no upper range, the following cases are only lower ranges.

  • ">=0"
  • ">0"

func IsRelease

func IsRelease(v string) bool

IsRelease returns true if the version is release version.

func IsUnboundedRange

func IsUnboundedRange(rng string) bool

IsUnboundedRange returns true if the given range is unbounded, the following cases are unbounded ranges.

  • ">=0"
  • "<6.3"

func IsUpperRangeOnly

func IsUpperRangeOnly(rng string) bool

IsUpperRangeOnly returns true if the given range has no lower range, the following cases are only upper ranges.

  • "<6.3"
  • "<=6.3"

func IsValid

func IsValid(v string) bool

IsValid returns true if the version is parse-able.

func Major

func Major(v string) string

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

func MajorMinor(v string) string

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

func RestrictUnboundedRange(w, ubrng string) (string, bool)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL