Documentation
¶
Overview ¶
Package update checks GitHub Releases for a newer pgtower and can replace the running binary in place. Everything is best-effort and offline-safe: a failed network call never breaks the app, it just means "no update offered".
Index ¶
- Constants
- func AssetName(version string) string
- func IsNewer(latest, current string) bool
- func IsRelease(v string) bool
- func Latest(ctx context.Context, repo string) (string, error)
- func OptOut() error
- func OptedOut() bool
- func SelfUpdate(ctx context.Context, repo, version string) error
- type ManualError
- type NameResult
Constants ¶
const LegacyName = "pgtui"
LegacyName is what the binary was called before v0.10.
const Repo = "9level/pgtower"
Repo is the canonical GitHub "owner/name" pgtower is released from.
Variables ¶
This section is empty.
Functions ¶
func AssetName ¶
AssetName is the release asset filename for the running platform, matching the names produced by the Makefile and consumed by install.sh.
func IsNewer ¶
IsNewer reports whether latest is strictly greater than current. If either is unparseable (e.g. current == "dev"), it returns false — never nag a build we can't reason about.
func IsRelease ¶
IsRelease reports whether v is a real version tag (so it makes sense to check for updates — dev/source builds are skipped).
func OptedOut ¶
func OptedOut() bool
OptedOut reports whether the user asked to never be prompted again.
func SelfUpdate ¶
SelfUpdate downloads the release binary for `version`, verifies its SHA256 and atomically replaces the running executable. It returns *ManualError when the install directory is not writable, so the caller can show manual steps.
Types ¶
type ManualError ¶
ManualError means pgtower could not replace its own binary (usually because the install directory needs root). It carries a ready-to-paste instruction.
func (*ManualError) Error ¶
func (e *ManualError) Error() string
func (*ManualError) Instructions ¶
func (e *ManualError) Instructions() string
Instructions returns a human-facing block explaining how to finish the update by hand.
type NameResult ¶
type NameResult struct {
Renamed bool // the binary now lives at Path
Path string // …/pgtower
Alias string // …/pgtui, now a symlink kept for old scripts ("" if none)
Manual string // instructions when it could not be done automatically
}
NameResult reports what AdoptName did.
func AdoptName ¶
func AdoptName(arg0 string) (NameResult, error)
AdoptName gives a pgtui-named binary its pgtower name. It runs when the program was started as "pgtui" — typically right after a v0.9 self-update, which replaces the old file in place. The binary is moved to "pgtower" in the same directory and "pgtui" becomes a symlink to it, so existing scripts and habits keep working. Nothing happens when already running as pgtower.