selfupdate

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseURL = "https://api.github.com"

BaseURL is the GitHub API base URL (override in tests with httptest).

View Source
var DirOverride string

DirOverride allows tests to redirect the cache to a temp directory.

View Source
var InstallDirOverride string

InstallDirOverride allows tests to override the install directory detection.

Functions

func CheckForUpdate

func CheckForUpdate(currentVersion string) string

CheckForUpdate fetches the latest release and returns the version if newer. Returns empty string if no update available or on any error.

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions returns -1 if a < b, 0 if a == b, 1 if a > b.

func ParseVersion

func ParseVersion(v string) ([3]int, error)

ParseVersion parses a semver string (with optional "v" prefix) into [major, minor, patch].

func ShouldCheck

func ShouldCheck(currentVersion string) bool

ShouldCheck returns true if >24h since last check and version is not "dev".

func Update

func Update(release *ReleaseResponse, out io.Writer) error

Update downloads and installs the release, replacing the current binary.

Types

type Asset

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

Asset is a single file attached to a GitHub release.

type CheckResult

type CheckResult struct {
	LatestVersion string    `json:"latest_version"`
	CheckedAt     time.Time `json:"checked_at"`
}

CheckResult is persisted between runs to throttle update checks.

type ReleaseResponse

type ReleaseResponse struct {
	TagName string  `json:"tag_name"`
	Assets  []Asset `json:"assets"`
}

ReleaseResponse is the subset of GitHub's release JSON we need.

func FetchLatestRelease

func FetchLatestRelease() (*ReleaseResponse, error)

FetchLatestRelease fetches the latest published release from GitHub. Returns nil, nil if no published release exists (404).

Jump to

Keyboard shortcuts

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