Documentation ¶
Overview ¶
Package versionfmt exposes functions to dynamically register formats used to parse Feature Versions.
Index ¶
Constants ¶
View Source
const ( // MinVersion is a special package version which is always sorted first. MinVersion = "#MINV#" // MaxVersion is a special package version which is always sorted last. MaxVersion = "#MAXV#" )
Variables ¶
View Source
var ( // ErrUnknownVersionFormat is returned when a function does not have enough // context to determine the format of a version. ErrUnknownVersionFormat = errors.New("unknown version format") // ErrInvalidVersion is returned when a function needs to validate a version, // but should return an error in the case where the version is invalid. ErrInvalidVersion = errors.New("invalid version") )
Functions ¶
func Compare ¶
Compare is a helper function that will compare two versions with a given format and return an error if there are any failures.
func GetFixedIn ¶
GetFixedIn is a helper function that computes the next fixed in version given a affected version range `rangeA`.
func RegisterParser ¶
RegisterParser provides a way to dynamically register an implementation of a Parser.
If RegisterParser is called twice with the same name, the name is blank, or if the provided Parser is nil, this function panics.
Types ¶
type Parser ¶
type Parser interface { // Valid attempts to parse a version string and returns its success. Valid(string) bool // Compare parses two different version strings. // Returns 0 when equal, -1 when a < b, 1 when b < a. Compare(a, b string) (int, error) // InRange computes if a is in range of b // // NOTE(Sida): For legacy version formats, rangeB is a version and // always use if versionA < rangeB as threshold. InRange(versionA, rangeB string) (bool, error) // GetFixedIn computes a fixed in version for a certain version range. // // NOTE(Sida): For legacy version formats, rangeA is a version and // be returned directly becuase it was considered fixed in version. GetFixedIn(rangeA string) (string, error) }
Parser represents any format that can compare two version strings.
Directories ¶
Path | Synopsis |
---|---|
Package dpkg implements a versionfmt.Parser for version numbers used in dpkg based software packages.
|
Package dpkg implements a versionfmt.Parser for version numbers used in dpkg based software packages. |
Package rpm implements a versionfmt.Parser for version numbers used in rpm based software packages.
|
Package rpm implements a versionfmt.Parser for version numbers used in rpm based software packages. |
Click to show internal directories.
Click to hide internal directories.