selfupdate

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(asset *Asset) error

Apply downloads the release asset and replaces the current binary.

func CheckInBackground

func CheckInBackground(currentVersion string, w io.Writer) func()

CheckInBackground performs a non-blocking update check and prints a notice if a newer version is available. Call from root command PersistentPreRun.

Returns a function that waits (up to a short timeout) for the background check to finish. The caller should defer this in main() so the goroutine has time to save its state before the process exits.

func CompareVersions

func CompareVersions(current, remote string) bool

CompareVersions returns true if remote is newer than current. Both should be semver strings like "v0.1.0" or "0.1.0".

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

func FindAsset

func FindAsset(release *Release) *Asset

FindAsset finds the matching release asset for the current platform.

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	HTMLURL string  `json:"html_url"`
	Body    string  `json:"body"`
	Assets  []Asset `json:"assets"`
}

func FetchLatestRelease

func FetchLatestRelease() (*Release, error)

type UpdateState

type UpdateState struct {
	LastChecked   time.Time `json:"last_checked"`
	LatestVersion string    `json:"latest_version"`
	ReleaseNotes  string    `json:"release_notes,omitempty"`
	ReleaseURL    string    `json:"release_url,omitempty"`
	NotifiedUser  bool      `json:"notified_user"`
}

Jump to

Keyboard shortcuts

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