Documentation
¶
Overview ¶
Package selfupdate provides CLI self-update functionality using GitHub releases.
Index ¶
Constants ¶
View Source
const ( // DefaultGitHubOwner is the default GitHub organization. DefaultGitHubOwner = "xenforo-ltd" // DefaultGitHubRepo is the default GitHub repository name. DefaultGitHubRepo = "cli" // GitHubAPIBase is the base URL for GitHub API. GitHubAPIBase = "https://api.github.com" // DownloadTimeout is the timeout for downloading updates. DownloadTimeout = 5 * time.Minute )
Variables ¶
View Source
var ( // ErrUpdateFailed indicates the update operation failed. ErrUpdateFailed = errors.New("update failed") // ErrChecksumMismatch indicates a checksum verification failure. ErrChecksumMismatch = errors.New("checksum mismatch") )
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
}
Asset represents a release asset (downloadable file).
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Assets []Asset `json:"assets"`
HTMLURL string `json:"html_url"`
}
Release represents a GitHub release.
type UpdateInfo ¶
type UpdateInfo struct {
CurrentVersion string
LatestVersion string
ReleaseURL string
AssetURL string
AssetName string
ChecksumURL string
HasUpdate bool
}
UpdateInfo contains information about an available update.
type Updater ¶
Updater handles checking for and applying updates.
func NewUpdater ¶
func NewUpdater() *Updater
NewUpdater creates a new updater with default GitHub repository settings.
func (*Updater) CheckForUpdate ¶
func (u *Updater) CheckForUpdate(ctx context.Context) (*UpdateInfo, error)
CheckForUpdate checks if an update is available on GitHub.
Click to show internal directories.
Click to hide internal directories.