update

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package update implements self-update for the kyc-cli binary.

Design (per user/security review):

  • Explicit `kyc-cli update` subcommand. Never auto-update silently.
  • On startup, optionally print a one-line nudge if a newer release is available and the user hasn't been told within the last 24h.
  • Refuse to overwrite the binary if it's owned by a package manager (Homebrew Cellar, Scoop, apt, etc.) — those users get told to use their package manager instead.
  • Verify the downloaded archive's sha256 against the release's checksums.txt before swapping.

No external Go deps — everything here is std lib + sha256 + tar.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLatest

func CheckLatest(ctx context.Context, current string) (string, error)

CheckLatest queries GitHub for the most recent (non-draft, non-pre) release. Returns ("", nil) if there's nothing newer than `current`. Returns the tag (e.g. "v0.1.6") if an upgrade is available.

func CheckLatestThrottled

func CheckLatestThrottled(ctx context.Context, current string) string

CheckLatestThrottled is CheckLatest with a 24h-on-disk cache so we only hit the GH API at most once per day per machine. Returns "" if either (a) no newer version, (b) we hit the cache and skipped, or (c) the network call failed (don't pester users on flaky networks).

func DoUpdate

func DoUpdate(ctx context.Context, tag string) error

DoUpdate downloads the matching tarball/zip for `tag`, verifies sha256 against checksums.txt, and atomically replaces the running binary. Returns nil on success.

func PackageManagerOrigin

func PackageManagerOrigin() string

PackageManagerOrigin returns a non-empty string when the running binary appears to live under a package manager's tree, signalling "tell the user to run brew/scoop/apt instead of self-update".

func PromptIfNewer

func PromptIfNewer(ctx context.Context, current string) bool

PromptIfNewer prints a one-line nudge to stderr (so it doesn't pollute stdout pipelines) if an update is available. Returns true if a nudge was printed.

Types

type LatestRelease

type LatestRelease struct {
	TagName    string `json:"tag_name"`
	HTMLURL    string `json:"html_url"`
	Prerelease bool   `json:"prerelease"`
	Draft      bool   `json:"draft"`
}

LatestRelease is the slice of the GitHub releases API we use.

Jump to

Keyboard shortcuts

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