Documentation
¶
Overview ¶
Package update implements background version checking and self-updating for the grut 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 ( // Sentinel errors for testable error checking via errors.Is(). ErrDevBuild = errors.New("cannot update a development build") ErrTooManyRedirects = errors.New("too many redirects") ErrPayloadTooLarge = errors.New("payload exceeds size limit") ErrUnsafeArchivePath = errors.New("unsafe archive entry path") ErrChecksumMismatch = errors.New("checksum mismatch") ErrChecksumNotFound = errors.New("no checksum found") ErrUnsupportedTarType = errors.New("unsupported tar entry type") ErrBinaryNotFound = errors.New("binary not found in archive") )
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 grut. 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(currentVersion string) *UpdateInfo
CheckForUpdate checks whether a newer version of grut 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.