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 ¶
- func CheckLatest(ctx context.Context, current string) (string, error)
- func CheckLatestThrottled(ctx context.Context, current string) string
- func DoUpdate(ctx context.Context, tag string) error
- func PackageManagerOrigin() string
- func PromptIfNewer(ctx context.Context, current string) bool
- type LatestRelease
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckLatest ¶
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 ¶
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 ¶
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".