version

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Latest = "latest"

Latest 指代当前最新版本

Variables

This section is empty.

Functions

func Semantify added in v1.6.0

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

Semantify go 版本号并未完全遵循语义化版本号标准,该函数进行了一定的适配,返回一个语义化版本。

func WithFinderGoarch added in v1.6.0

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

WithFinderGoarch 设置查找器所在的目标硬件架构,如386, amd64, arm, s390x等。

func WithFinderGoos added in v1.6.0

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

WithFinderGoos 设置查找器所在的目标操作系统,如darwin, freebsd, linux等。

func WithFinderPackageKind added in v1.6.0

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

WithFinderPackageKind 设置查找器查找的文件种类。

func WithPackages added in v1.6.0

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

WithPackages 设置版本下的软件包列表

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 版本查找器

func NewFinder added in v1.6.0

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

NewFinder 返回

func (*Finder) Find added in v1.6.0

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

Find 返回满足条件的语义化版本号。版本格式:主版本号.次版本号.修订号。 vname 支持以下几类版本标识: 1、具体版本号:如'1.21.4' 2、最新版本:latest 3、通配符:如'1.21.x'、'1.x'、'1.18.*'等 4、匹配最新的次版本号(主版本号兼容):如'^1'、'^1.18'、'^1.18.10'等,在主版本号保持一致的前提下,次版本号和修订号均保持最新。 5、匹配某个次版本号的最新修订号:如'~1.18',在主次版本号保持一致的前提下,修订号保持最新。 6、匹配大于目标版本的最新版本:如'>1.18',大于该版本的前提下,匹配最大的版本号。 7、匹配小于目标版本的最新版本:如'<1.16',小于该版本的前提下,匹配最大的版本号。 8、匹配目标版本区间内的最新版本:如'1.18 - 1.20',匹配该区间范围内的最大版本。

func (*Finder) MustFind added in v1.6.0

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

MustFind 返回满足条件的语义化版本号。若发生错误,则抛出panic。

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 go版本安装包

func (*Package) DownloadWithProgress added in v1.2.0

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

DownloadWithProgress 下载版本另存为指定文件且显示下载进度

func (*Package) VerifyChecksum

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

VerifyChecksum 验证目标文件的校验和与当前安装包的校验和是否一致

type PackageKind added in v1.6.0

type PackageKind string

PackageKind 软件包种类

const (
	// SourceKind go安装包种类-源码
	SourceKind PackageKind = "Source"
	// ArchiveKind go安装包种类-压缩文件
	ArchiveKind PackageKind = "Archive"
	// InstallerKind go安装包种类-可安装程序
	InstallerKind PackageKind = "Installer"
)

type Version

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

Version go版本

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)

func (*Version) FindPackages added in v1.1.2

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

FindPackages 返回指定操作系统和硬件架构的版本包

func (*Version) MatchConstraint added in v1.6.0

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

MatchConstraint 检查当前版本是否满足约束条件

func (*Version) Name

func (v *Version) Name() string

Name 返回版本号

func (*Version) Packages

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

Packages 返回软件包列表

Jump to

Keyboard shortcuts

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