version

package
v3.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CliSeparator is used in commands to specify version. E.g: program=version.
	CliSeparator = "="
	// FsSeparator is used in file names to specify version. E.g: program_version.
	FsSeparator = "_"
)
View Source
const (

	// DefaultTitle is the name tt presents itself under.
	DefaultTitle = "Tarantool CLI"
)

Variables

View Source
var (
	// ErrNotFound reports that no available version matches the requested version.
	ErrNotFound = errors.New("version not found")

	// ErrInstalledVersionNotFound reports a request matching no installed version.
	ErrInstalledVersionNotFound = errors.New("installed version not found")
	// ErrAmbiguousInstalledVersion reports a request matching multiple installed versions.
	ErrAmbiguousInstalledVersion = errors.New("more than one installed version matches")
)

Functions

func FormatModules

func FormatModules(versions []ModuleVersion) string

FormatModules renders versions one module per line - its name, its version and its Go module - in aligned columns, each line indented by two spaces and ended with a newline.

func GetVersion

func GetVersion(showShort, needCommit bool) string

GetVersion returns the version of the tt core, in the forms Flavour.GetVersion describes. It is the version the core is, whichever distribution of tt runs it.

func IsLess

func IsLess(verLeft, verRight Version) bool

IsLess returns true if verLeft is less than verRight.

func IsNumericVersion

func IsNumericVersion(requested string) bool

IsNumericVersion reports whether the request has the form X, X.Y, or X.Y.Z.

func IsVersion

func IsVersion(version string) bool

IsVersion reports whether the string matches a version or a partial version mask.

func MatchInstalledVersion

func MatchInstalledVersion(requested string, installed []string) (string, error)

MatchInstalledVersion resolves X.Y.Z or an exact installation name. A numeric request must match exactly one build, including prereleases and revisions. Partial numbers are never expanded. Literal names such as commit hashes match exactly.

func MatchVersion

func MatchVersion(expected string, sortedVersions []Version) (string, error)

MatchVersion takes as input an ascending sorted list of versions. In which it finds the latest version matching the search mask.

It returns NotFoundError wrapping ErrNotFound when no version matches.

func Stamp

func Stamp() string

Stamp returns the version of the tt core the files tt writes record as their author, as in generated_by = "tt <Stamp>" of a lock: the short version of the core; or, for a build no tag the build knows precedes - a development build from a checkout, say - the exact module version Go recorded, a pseudo-version that names the commit; or the commit alone. It is <unknown> only when the build tells none of them.

Types

type Flavour

type Flavour struct {
	// Title is the distribution's name. Empty means DefaultTitle.
	Title string
	// Version is the distribution's version. Nil means the core's.
	Version *Info
	// Edition, when set, follows the short version as semver build
	// metadata: 2.15.0+ee.
	Edition string
}

Flavour is how a distribution of tt presents itself: its name and its version. The zero Flavour is tt's own.

func (Flavour) CoreVersion

func (f Flavour) CoreVersion() (string, bool)

CoreVersion returns the line tt version shows under the version of a distribution with a version of its own: the version of the tt core it is built on, with the commit. It reports false for a distribution without a version of its own, tt's among them, whose version is the core's.

func (Flavour) Custom

func (f Flavour) Custom() bool

Custom reports whether the distribution presents itself under a name other than tt's own.

func (Flavour) GetVersion

func (f Flavour) GetVersion(showShort, needCommit bool) string

GetVersion returns the distribution's version: in full with its name, the platform and the commit; short, the version alone; or, with needCommit, the version followed by the commit. The edition follows the version in the short forms.

func (Flavour) Name

func (f Flavour) Name() string

Name returns the name the distribution presents itself under.

type Info

type Info struct {
	// Tag is the tag the build is at or descends from, as git describe
	// prints it: v2.15.0, or v2.15.0-3-gabc1234 for a commit past it. The
	// version keeps the tag's pre-release but not the commit count and hash.
	// Empty means the version is unknown.
	Tag string
	// Commit is the abbreviated hash of the commit built.
	Commit string
	// CommitsSinceTag is the number of commits between Tag and Commit. When
	// it is not zero the full version shows Tag as well.
	CommitsSinceTag int
	// Label, when set, follows the version: 2.15.0/label.
	Label string
}

Info describes what a build was made from.

type Module

type Module struct {
	// Name is the name the table gives the module.
	Name string
	// Package is the import path of the package of the module's
	// constructor.
	Package string
}

Module is a module tt is built from, as the table of the core names it.

type ModuleVersion

type ModuleVersion struct {
	// Name is the name the table of the core gives the module.
	Name string
	// Path is the path of the Go module, empty when the build info does not
	// record the module of the constructor.
	Path string
	// Version is the version of the Go module: its own, or the version of
	// its replacement when it is replaced by another module, (devel) when it
	// is built from a directory, <unknown> when it is not recorded.
	Version string
	// Replace is the path of the module that replaces it, when that is
	// another module; empty otherwise.
	Replace string
}

ModuleVersion is a module with the Go module its constructor comes from, as the build info of the binary records it.

func ModuleVersions

func ModuleVersions(modules []Module) []ModuleVersion

ModuleVersions returns the Go modules the constructors of modules come from, in the order of modules, as the build info of the binary records them.

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

NotFoundError reports a version request that could not be matched.

func (NotFoundError) Error

func (e NotFoundError) Error() string

Error implements the [error] interface.

func (NotFoundError) Unwrap

func (e NotFoundError) Unwrap() error

Unwrap allows errors.Is to recognize ErrNotFound while retaining the requested version.

type Release

type Release struct {
	Type ReleaseType
	Num  uint64
	// contains filtered or unexported fields
}

func (Release) String

func (release Release) String() string

type ReleaseType

type ReleaseType uint16
const (
	TypeNightly ReleaseType = iota
	TypeAlpha
	TypeBeta
	TypeRC
	TypeRelease
)

type Version

type Version struct {
	Major      uint64  // Major.
	Minor      uint64  // Minor.
	Patch      uint64  // Patch.
	Additional uint64  // Additional commits.
	Revision   uint64  // Revision number.
	Release    Release // Release type.
	Hash       string  // Commit hash.
	Str        string  // String representation.
	Tarball    string  // Tarball name.
	BuildName  string  // Custom build name.
}

func Parse

func Parse(verStr string) (Version, error)

Parse parses a version string and return the version value it represents.

func ParseTt

func ParseTt(verStr string) (Version, error)

ParseTt parses a tt version string with format '<major>.<minor>.<patch>.<hash>' and return the version value it represents. A build of a pre-release tag names it as '<major>.<minor>.<patch>-<pre-release>.<hash>', and the numbers come from the version without the pre-release.

type VersionSlice

type VersionSlice []Version

VersionSlice attaches the methods of sort.Interface to []Version, sorting from oldest to newest.

func (VersionSlice) Len

func (v VersionSlice) Len() int

Len implements sort.Interface.

func (VersionSlice) Less

func (v VersionSlice) Less(i, j int) bool

Less implements sort.Interface, sorting from oldest to newest.

func (VersionSlice) Swap

func (v VersionSlice) Swap(i, j int)

Swap implements sort.Interface.

Jump to

Keyboard shortcuts

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