Documentation
¶
Index ¶
- type MajorVersion
- func (m MajorVersion) AtLeast(o MajorVersion) bool
- func (m MajorVersion) Compare(o MajorVersion) int
- func (m MajorVersion) Empty() bool
- func (m MajorVersion) Equals(o MajorVersion) bool
- func (m MajorVersion) LessThan(o MajorVersion) bool
- func (m MajorVersion) SafeFormat(p redact.SafePrinter, _ rune)
- func (m MajorVersion) String() string
- type NullVersion
- type Version
- func (v Version) AtLeast(w Version) bool
- func (v Version) Compare(w Version) int
- func (v Version) CompareSeries(w Version) int
- func (v Version) Empty() bool
- func (v Version) Equals(w Version) bool
- func (v Version) Format(formatStr string) string
- func (v Version) IncPatch() (Version, error)
- func (v Version) IncPreRelease() (Version, error)
- func (v Version) IsAdhocBuild() bool
- func (v Version) IsCloudOnlyBuild() bool
- func (v Version) IsCustomBuild() bool
- func (v Version) IsCustomOrAdhocBuild() bool
- func (v Version) IsPrerelease() bool
- func (v Version) LessThan(w Version) bool
- func (v Version) Major() MajorVersion
- func (v Version) MarshalJSON() ([]byte, error)
- func (v Version) Patch() int
- func (v Version) SafeFormat(p redact.SafePrinter, _ rune)
- func (v *Version) Scan(value interface{}) error
- func (v Version) String() string
- func (v *Version) UnmarshalJSON(data []byte) error
- func (v Version) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MajorVersion ¶
type MajorVersion struct {
Year, Ordinal int
}
A MajorVersion represents a CockroachDB major version or release series, ie "v25.1".
func MustParseMajorVersion ¶
func MustParseMajorVersion(versionStr string) MajorVersion
MustParseMajorVersion is like ParseMajorVersion but panics on any error. Recommended as an initializer for global values.
func ParseMajorVersion ¶
func ParseMajorVersion(versionStr string) (MajorVersion, error)
ParseMajorVersion constructs a MajorVersion from a string.
func (MajorVersion) AtLeast ¶
func (m MajorVersion) AtLeast(o MajorVersion) bool
func (MajorVersion) Compare ¶
func (m MajorVersion) Compare(o MajorVersion) int
Compare returns -1, 0, or +1 indicating the relative ordering of major versions.
func (MajorVersion) Empty ¶
func (m MajorVersion) Empty() bool
Empty returns true if the MajorVersion is the zero value.
func (MajorVersion) Equals ¶
func (m MajorVersion) Equals(o MajorVersion) bool
func (MajorVersion) LessThan ¶
func (m MajorVersion) LessThan(o MajorVersion) bool
func (MajorVersion) SafeFormat ¶
func (m MajorVersion) SafeFormat(p redact.SafePrinter, _ rune)
SafeFormat implements redact.SafeFormatter.
func (MajorVersion) String ¶
func (m MajorVersion) String() string
String returns the original string passed to ParseMajorVersion.
type NullVersion ¶
Represents a NULLable version when stored in the database. The zero value of NullVersion serializes as database NULL (and vice-versa).
func NewNullVersion ¶
func NewNullVersion(v Version) NullVersion
func (*NullVersion) Scan ¶
func (n *NullVersion) Scan(value interface{}) error
Scan implements sql.Scanner, and is used when deserializing a NullVersion from the db.
func (*NullVersion) UnmarshalJSON ¶
func (n *NullVersion) UnmarshalJSON(data []byte) error
We must implement json.Unmarshaler, because the invalid NullVersion stores an empty string in the version field, and we don't want to make Version unmarshal successfully from empty string (it should and does maintain the same behavior as Parse).
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version represents a CockroachDB (binary) version. Versions consist of three parts: a major version, written as "vX.Y" (which is typically the year and release number within the year), a patch version (the "Z" in "vX.Y.Z"), and sometimes one or more phases, sub-phases, and other suffixes. Note that CockroachDB versions are not semantic versions! You must use this package to parse and compare versions, in order to account for the variety of versions currently or historically in use.
func MustParse ¶
MustParse is like Parse but panics on any error. Recommended as an initializer for global values.
func (Version) Compare ¶
Compare returns -1, 0, or +1 indicating the relative ordering of versions.
CockroachDB versions are not semantic versions. SemVer treats suffixes after the major.minor.patch quite generically; we have specific, known cases that have well-defined ordering requirements:
There are 4 known named prerelease phases. In order, they are: alpha, beta, rc, cloudonly. Pre-release versions will look like "v24.1.0-cloudonly.1" or "v23.2.0-rc.1".
Additionally, we have adhoc builds, which have suffixes like "-<n>-g<hex>", where <n> is an integer commit count past the branch point, and <hex> is the git SHA. These versions sort AFTER the corresponding "normal" version, eg "v24.1.0-1-g9cbe7c5281" is AFTER "v24.1.0".
A version can have both a pre-release and adhoc build suffix, like "v24.1.0-rc.2-14-g<hex>". In these cases, the pre-release portion has precedence, so this example would sort after v24.1.0-rc.2, but before v24.1.0-rc.3.
func (Version) CompareSeries ¶
Convenience wrapper for v.Major.Compare(w.Major())
func (Version) Format ¶
Format returns a string populated with parts of the version, using placeholders similar to the fmt package. The following placeholders are supported:
- %X: year - %Y: ordinal - %Z: patch - %P: phase name (one of "alpha", "beta", "rc", "cloudonly") - %p: phase sort order (see the top of version.go) - %o: phase ordinal (eg, the 1 in "v24.1.0-rc.1") - %s: phase sub-ordinal (eg the 2 in "v24.1.0-rc.1-cloudonly.2") - %n: adhoc build ordinal (eg the 12 in "v24.1.0-12-gabcdef") - %%: literal "%"
func (Version) IncPatch ¶
IncPatch returns a new version with the patch number incremented by 1. This method returns an error if the version is not a stable version.
func (Version) IncPreRelease ¶
IncPreRelease returns a new version with the pre-release part incremented by 1. This method returns an error if the version is not a pre-release.
func (Version) IsAdhocBuild ¶
IsAdhocBuild determines if the version is a adhoc build.
func (Version) IsCloudOnlyBuild ¶
IsCloudOnlyBuild determines if the version is a CockroachDB Cloud specific build.
func (Version) IsCustomBuild ¶
IsCustomBuild determines if the version is a adhoc build.
func (Version) IsCustomOrAdhocBuild ¶
IsCustomOrAdhocBuild determines if the version is a adhoc build or adhoc build.
func (Version) IsPrerelease ¶
IsPrerelease determines whether the version is a pre-release version.
func (Version) Major ¶
func (v Version) Major() MajorVersion
Major returns the version's MajorVersion (the "vX.Y" part)
func (Version) MarshalJSON ¶
MarshalJSON implements encoding/json.Marshaler.
func (Version) SafeFormat ¶
func (v Version) SafeFormat(p redact.SafePrinter, _ rune)
SafeFormat implements redact.SafePrinter.
func (*Version) Scan ¶
Scan implements database/sql.Scanner.
func (*Version) UnmarshalJSON ¶
UnmarshalJSON implements encoding/json.Unmarshaler.