version

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Latest = "latest"

Latest represents the current stable release.

Variables

This section is empty.

Functions

func Semantify added in v1.6.0

func Semantify(vname string) (*semver.Version, error)

Semantify converts Go version strings to semantic version format with adaptation.

func WithFinderGoarch added in v1.6.0

func WithFinderGoarch(goarch string) func(fdr *Finder)

WithFinderGoarch sets target machine architecture (e.g. 386, amd64, arm, s390x).

func WithFinderGoos added in v1.6.0

func WithFinderGoos(goos string) func(fdr *Finder)

WithFinderGoos sets target operating system (e.g. darwin, freebsd, linux).

func WithFinderPackageKind added in v1.6.0

func WithFinderPackageKind(kind PackageKind) func(fdr *Finder)

WithFinderPackageKind sets the package kind to search for.

func WithPackages added in v1.6.0

func WithPackages(pkgs []*Package) func(v *Version)

WithPackages configures available distribution packages for the version.

Types

type Collection added in v1.6.0

type Collection []*Version

func (Collection) Len added in v1.6.0

func (c Collection) Len() int

func (Collection) Less added in v1.6.0

func (c Collection) Less(i, j int) bool

func (Collection) Swap added in v1.6.0

func (c Collection) Swap(i, j int)

type Finder added in v1.6.0

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

Finder implements version lookup for Go language distributions.

func NewFinder added in v1.6.0

func NewFinder(items []*Version, opts ...func(fdr *Finder)) *Finder

NewFinder creates a new Finder instance with sorted versions and applied options.

func (*Finder) Find added in v1.6.0

func (fdr *Finder) Find(vname string) (*Version, error)

Find returns semantic version matching criteria.

Supported patterns:
1. Specific version (e.g. '1.21.4')
2. Latest version identifier 'latest'
3. Wildcards (e.g. '1.21.x', '1.x', '1.18.*')
4. Caret ranges for minor version compatibility (e.g. '^1', '^1.18', '^1.18.10')
5. Tilde ranges for patch version updates (e.g. '~1.18')
6. Greater than comparisons (e.g. '>1.18')
7. Less than comparisons (e.g. '<1.16')
8. Version ranges (e.g. '1.18-1.20')

func (*Finder) MustFind added in v1.6.0

func (fdr *Finder) MustFind(vname string) *Version

MustFind returns matched version or panics on error.

type Package

type Package struct {
	FileName    string      `json:"filename"`
	URL         string      `json:"url"`
	Kind        PackageKind `json:"kind"`
	OS          string      `json:"os"`
	Arch        string      `json:"arch"`
	Size        string      `json:"size"`
	Checksum    string      `json:"checksum"`
	ChecksumURL string      `json:"-"`
	Algorithm   string      `json:"algorithm"` // checksum algorithm
}

Package describes a Go distribution file metadata.

func (*Package) DownloadWithProgress added in v1.2.0

func (pkg *Package) DownloadWithProgress(dst string) (size int64, err error)

DownloadWithProgress fetches package with real-time download metrics.

func (*Package) VerifyChecksum

func (pkg *Package) VerifyChecksum(filename string) (err error)

VerifyChecksum validates downloaded file against cryptographic hash.

type PackageKind added in v1.6.0

type PackageKind string

PackageKind indicates distribution package format type.

const (
	// SourceKind indicates source code package
	SourceKind PackageKind = "Source"
	// ArchiveKind indicates compressed archive package
	ArchiveKind PackageKind = "Archive"
	// InstallerKind indicates executable installer
	InstallerKind PackageKind = "Installer"
)

type Version

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

Version represents a Go language distribution version.

func MustNew added in v1.6.0

func MustNew(name string, opts ...func(v *Version)) *Version

func New added in v1.6.0

func New(name string, opts ...func(v *Version)) (*Version, error)

New creates a Version instance with semantic version validation.

func (*Version) FindPackages added in v1.1.2

func (v *Version) FindPackages(kind PackageKind, goos, goarch string) (pkgs []Package, err error)

FindPackages discovers packages matching specific OS/ARCH and package type.

func (*Version) MatchConstraint added in v1.6.0

func (v *Version) MatchConstraint(c *semver.Constraints) bool

MatchConstraint checks if version satisfies semantic version constraints.

func (*Version) Name

func (v *Version) Name() string

Name returns original version string (e.g. 'go1.21.4').

func (*Version) Packages

func (v *Version) Packages() []Package

Packages returns all distribution packages for different OS/ARCH combinations.

Jump to

Keyboard shortcuts

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