Documentation
¶
Index ¶
- func DefaultProgressTracker() getter.ProgressTracker
- type Api
- type Downloader
- func (f *Downloader) DownloadAsset(assetName, version, dest string) error
- func (f *Downloader) DownloadAssetWithContext(ctx context.Context, assetName, version, dest string) error
- func (f *Downloader) DownloadLatestAsset(pattern string, dest string) error
- func (f *Downloader) GetLatestReleaseAssets() ([]string, error)
- func (f *Downloader) GetReleaseAssetURL(assetName string) (string, error)
- func (f *Downloader) GetReleaseAssetURLByVersion(assetName, version string) string
- func (f *Downloader) LatestVersion() (string, error)
- type Install
- type RepoApi
- type VersionApi
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultProgressTracker ¶
func DefaultProgressTracker() getter.ProgressTracker
DefaultProgressTracker returns the default ProgressTracker that prints download progress to stdout.
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
Api 结构体用于配置和执行下载安装操作
func (*Api) SetProgressTracker ¶
func (a *Api) SetProgressTracker(pt getter.ProgressTracker) *Api
SetProgressTracker 设置进度跟踪器
func (*Api) SetRetryTimeDelay ¶
SetRetryTimeDelay 设置重试延迟时间(秒)
type Downloader ¶
type Downloader struct {
// RetryCount is how many times the package will retry to obtain the latest version.
RetryCount int
// RetryDelay is the delay between retries when obtaining the latest version.
RetryDelay time.Duration
// ApiURL is the GitHub API URL for fetching the latest release.
ApiURL string
// Repo is the GitHub repository in format "owner/repo".
Repo string
// Proxy is the HTTP proxy to use for downloads.
Proxy string
// ProgressTracker is the progress tracker to use for downloads.
ProgressTracker getter.ProgressTracker
}
func NewDownloader ¶
func NewDownloader(repo string) *Downloader
func NewDownloaderWithConfig ¶
func NewDownloaderWithConfig(repo string, retryCount int, retryDelay time.Duration, proxy string, progressTracker getter.ProgressTracker) *Downloader
func (*Downloader) DownloadAsset ¶
func (f *Downloader) DownloadAsset(assetName, version, dest string) error
DownloadAsset downloads a specific asset from the latest release of the repository. assetName is the name of the asset to download. dest is the destination directory for the downloaded asset.
func (*Downloader) DownloadAssetWithContext ¶
func (f *Downloader) DownloadAssetWithContext(ctx context.Context, assetName, version, dest string) error
DownloadAssetWithContext downloads a specific asset from a release using the provided context and progress tracker. assetName is the name of the asset to download. version is the release version to download from (empty string for latest). dest is the destination directory for the downloaded asset.
func (*Downloader) DownloadLatestAsset ¶
func (f *Downloader) DownloadLatestAsset(pattern string, dest string) error
DownloadLatestAsset downloads the latest asset that matches a pattern from the repository. pattern is a regex pattern to match against asset names. dest is the destination directory for the downloaded asset.
func (*Downloader) GetLatestReleaseAssets ¶
func (f *Downloader) GetLatestReleaseAssets() ([]string, error)
GetLatestReleaseAssets returns a list of asset names from the latest release.
func (*Downloader) GetReleaseAssetURL ¶
func (f *Downloader) GetReleaseAssetURL(assetName string) (string, error)
GetReleaseAssetURL returns the download URL for a specific asset in the latest release.
func (*Downloader) GetReleaseAssetURLByVersion ¶
func (f *Downloader) GetReleaseAssetURLByVersion(assetName, version string) string
GetReleaseAssetURLByVersion returns the download URL for a specific asset in a specific release version.
func (*Downloader) LatestVersion ¶
func (f *Downloader) LatestVersion() (string, error)
LatestVersion fetches the latest release tag from the GitHub API for the specified repository.
type Install ¶
type Install struct {
InstallPath string
Downloader *Downloader
// contains filtered or unexported fields
}
Install struct holds common variables for installation operations
func NewInstall ¶
NewInstall creates a new Install instance with default values
func (*Install) CreateVersionFile ¶
CreateVersionFile creates a version info file in the specified directory.
func (*Install) GetInstalledVersion ¶
func (i *Install) GetInstalledVersion() (*VersionInfo, error)
GetInstalledVersion returns the installed version information for the specified path.
type RepoApi ¶
type RepoApi struct {
// contains filtered or unexported fields
}
RepoApi 结构体用于指定 GitHub 仓库
func (*RepoApi) GetInstalledVersion ¶
func (r *RepoApi) GetInstalledVersion() (*VersionInfo, error)
GetInstalledVersion 获取已安装的版本信息
func (*RepoApi) Version ¶
func (r *RepoApi) Version(version string) *VersionApi
Version 设置具体版本,返回 VersionApi
type VersionApi ¶
type VersionApi struct {
// contains filtered or unexported fields
}
VersionApi 结构体用于指定版本