update

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 20 Imported by: 0

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

This section is empty.

Functions

func AssetName

func AssetName(version string) string

AssetName returns the expected release archive filename for the current platform and architecture.

func CompareVersions

func CompareVersions(a, b string) int

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

func ParseChecksum(content, filename string) (string, error)

ParseChecksum extracts the SHA-256 hash for a specific file from a checksums.txt file in "hash filename\n" format.

func RunUpdate

func RunUpdate(currentVersion string) error

RunUpdate downloads and installs the latest version of dispatch. It prints progress to stderr and returns an error on failure.

func SHA256File

func SHA256File(path string) (string, error)

SHA256File computes the SHA-256 hash of a file and returns it as a lowercase hex string.

Types

type UpdateInfo

type UpdateInfo struct {
	CurrentVersion string
	LatestVersion  string
	ReleaseURL     string
}

UpdateInfo describes an available update.

func CheckForUpdate

func CheckForUpdate(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.

Jump to

Keyboard shortcuts

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