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 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) }
Parser represents any format that can compare two version strings.
Click to show internal directories.
Click to hide internal directories.