util

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	// ErrUnsupportedChecksumAlgorithm 不支持的校验和算法
	ErrUnsupportedChecksumAlgorithm = errors.New("unsupported checksum algorithm")
	// ErrChecksumNotMatched 校验和不匹配
	ErrChecksumNotMatched = errors.New("file checksum does not match the computed checksum")
)
View Source
var ErrPackageNotFound = errors.New("installation package not found")

ErrPackageNotFound 版本包不存在

View Source
var ErrVersionNotFound = errors.New("version not found")

ErrVersionNotFound 版本不存在

Functions

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory. We pass an io.TeeReader into Copy() to report progress on the download.

func NewDownloadError

func NewDownloadError(url string, err error) error

NewDownloadError 返回下载失败错误实例

func PathExists

func PathExists(path string) (bool, error)

PathExists 判断一个文件或文件夹是否存在 输入文件路径,根据返回的bool值来判断文件或文件夹是否存在

func Process

func Process()

Types

type Bar

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

func NewOption

func NewOption(start, total int64) *Bar

func NewOptionWithGraph

func NewOptionWithGraph(start, total int64, graph string) *Bar

func (*Bar) Play

func (bar *Bar) Play()

func (*Bar) Write

func (bar *Bar) Write(p []byte) (int, error)

type DownloadError

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

DownloadError 下载失败错误

func (*DownloadError) Error

func (e *DownloadError) Error() string

type FindPackageInterface

type FindPackageInterface interface {
	FindPackage(king, goos, arch string) (*Package, error)
}

type Package

type Package struct {
	FileName    string
	ArchiveName string
	URL         string
	Kind        string
	OS          string
	Arch        string
	Size        string
	Checksum    string
	Algorithm   string // checksum algorithm
}

Package 版本安装包

func (*Package) Download

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

Download 下载版本另存为指定文件并校验sha256哈希值

func (*Package) DownloadV2

func (pkg *Package) DownloadV2(dst string) (err error)

DownloadV2 下载版本另存为指定文件并校验sha256哈希值

func (*Package) VerifyChecksum

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

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

type Version

type Version struct {
	Name     string // 版本名,如'1.12.4'
	Packages []*Package
}

Version 版本

func FindVersion

func FindVersion(all []*Version, name string) (*Version, error)

FindVersion 返回指定名称的版本

func FindVersionV2

func FindVersionV2(all map[string]*Version, name string) (*Version, error)

FindVersionV2 返回指定名称的版本

Jump to

Keyboard shortcuts

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