selfupdate

package
v0.1.7-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 19 Imported by: 0

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"`
	Size               int64  `json:"size"`
	ContentType        string `json:"content_type"`
}

Asset represents a release asset (downloadable file).

type Release

type Release struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Prerelease  bool      `json:"prerelease"`
	Draft       bool      `json:"draft"`
	PublishedAt time.Time `json:"published_at"`
	Body        string    `json:"body"`
	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
	ReleaseNotes   string
	AssetURL       string
	AssetName      string
	ChecksumURL    string
	HasUpdate      bool
}

UpdateInfo contains information about an available update.

type Updater

type Updater struct {
	GitHubOwner string
	GitHubRepo  string
	HTTPClient  *http.Client
}

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.

func (*Updater) Update

func (u *Updater) Update(ctx context.Context, info *UpdateInfo, progressFn func(downloaded, total int64)) error

Update downloads and applies the new version.

Jump to

Keyboard shortcuts

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