update

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package update polls GitHub once a day for newer yottacode releases and caches the answer under ~/.yottacode/cache/update-check.json. Callers spin up CheckBackground at startup and react to the at-most- one Result that arrives — failures are silent so the update path never blocks or annoys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBackground

func CheckBackground(ctx context.Context) <-chan Result

CheckBackground starts an async check. The returned channel receives exactly one Result on success, then closes. On any failure (no HOME, network error, parse error, ...) the channel closes with no value. Silent failure is intentional: an update check must never block startup or annoy.

func InstallRelease

func InstallRelease(ctx context.Context, ver string) error

InstallRelease upgrades the running binary to the given version by downloading the matching release archive, verifying it against the release's SHA256SUMS file, extracting the binary, and atomically replacing the current executable.

This replaces the old `curl … | bash` install path: nothing is piped to a shell, and the download is rejected unless its SHA-256 matches the SHA256SUMS checksum manifest published alongside the release. The manifest is fetched over HTTPS from the same GitHub release, so this verifies integrity (no corrupt or partial download installs) and pins the exact version — it is not an end-to-end signature check, which would require a separately-trusted signing key. Any failure — network, checksum mismatch, missing asset — returns an error without touching the installed binary.

ver is the target version without a leading "v" (e.g. "0.3.0"), matching update.Result.Latest.

Types

type Result

type Result struct {
	Current    string // e.g. "0.2.0"
	Latest     string // e.g. "0.3.0", no leading "v"
	URL        string // GitHub release HTML URL
	NewVersion bool   // Latest > Current per semver
}

Result is what CheckBackground delivers when a check succeeds.

Jump to

Keyboard shortcuts

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