Documentation
¶
Overview ¶
Package update implements background version checking and self-updating for the dispatch CLI. Versions are fetched from GitHub Releases and verified via SHA-256 checksums before replacing the running binary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsafeArchivePath = errors.New("unsafe archive entry path") ErrUnsupportedTarEntry = errors.New("unsupported tar entry type") ErrNonHTTPS = errors.New("refusing redirect to non-HTTPS URL") ErrTooManyRedirects = errors.New("too many redirects") ErrDownloadExceeded = errors.New("download exceeds size limit") ErrChecksumMismatch = errors.New("checksum mismatch") ErrPayloadExceeded = errors.New("payload exceeds size limit") ErrLockExists = errors.New("lock file exists") ErrCheckingVersion = errors.New("checking latest version") ErrInvalidVersion = errors.New("invalid latest version") ErrDownloading = errors.New("downloading") ErrDownloadingChecksums = errors.New("downloading checksums") ErrExtractingBinary = errors.New("extracting binary") ErrOpeningBinary = errors.New("opening new binary") ErrOpeningArchive = errors.New("opening archive") ErrOpeningZip = errors.New("opening zip") ErrComputingChecksum = errors.New("computing checksum") ErrHTTPStatus = errors.New("unexpected HTTP status") )
Sentinel errors returned by update operations.
Functions ¶
func AssetName ¶
AssetName returns the expected release archive filename for the current platform and architecture.
func CompareVersions ¶
CompareVersions compares two semantic version strings (e.g. "1.2.3"). Returns -1 if a < b, 0 if a == b, 1 if a > b. A leading "v" prefix is stripped. Non-numeric parts are treated as 0.
func ParseChecksum ¶
ParseChecksum extracts the SHA-256 hash for a specific file from a checksums.txt file in "hash filename\n" format.
func RunUpdate ¶
RunUpdate downloads and installs the latest version of dispatch. It prints progress to stderr and returns an error on failure.
func SHA256File ¶
SHA256File computes the SHA-256 hash of a file and returns it as a lowercase hex string.
Types ¶
type UpdateInfo ¶
UpdateInfo describes an available update.
func CheckForUpdate ¶
func CheckForUpdate(ctx context.Context, currentVersion string) *UpdateInfo
CheckForUpdate checks whether a newer version of dispatch is available on GitHub. It returns nil if the current version is up to date, is a dev build, or any error occurs. This function is safe to call from a goroutine — it never panics and silently returns nil on all errors.