Documentation
¶
Overview ¶
Package update implements background version checking against GitHub Releases with a 24-hour state file cache to avoid redundant API calls.
homebrew.go detects whether initech was installed via Homebrew and adapts update behavior accordingly. Homebrew installations must use `brew upgrade` instead of self-updating to keep Homebrew's version tracking correct.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var APIBaseURL = "https://api.github.com"
APIBaseURL is the GitHub API base. Override in tests.
var InstallMethod string
InstallMethod is set at compile time via ldflags:
-X github.com/nmelo/initech/internal/update.InstallMethod=homebrew (Homebrew formula) -X github.com/nmelo/initech/internal/update.InstallMethod=release (GitHub Release)
Empty string means unknown (development builds, go install).
Functions ¶
func CanSelfUpdate ¶
func CanSelfUpdate() bool
CanSelfUpdate returns true if the binary can safely self-update without conflicting with a package manager. False for Homebrew installations (detected via compile-time flag or runtime path check).
func IsUnderHomebrew ¶
func IsUnderHomebrew() bool
IsUnderHomebrew returns true if the running binary lives inside Homebrew's prefix directory (e.g., /opt/homebrew/bin/ or /usr/local/bin/ on Intel Macs). Falls back to false on any error (brew not installed, symlink resolution fails, etc.).
func ShouldCheck ¶
func ShouldCheck() bool
ShouldCheck returns false when version checking should be suppressed (CI environments, explicit opt-out, non-interactive).
func ShouldSuppressNotification ¶
ShouldSuppressNotification returns true if the update notification should be suppressed because the release is too new for Homebrew to have updated its formula. Homebrew formula updates are typically batched and can take up to 24 hours after a GitHub Release is published.
func UpdateInstruction ¶
func UpdateInstruction() string
UpdateInstruction returns the appropriate update command for the user. Homebrew installations get "brew upgrade initech"; others get "initech update".
Types ¶
type ReleaseInfo ¶
type ReleaseInfo struct {
Version string `json:"version"`
URL string `json:"url"`
PublishedAt time.Time `json:"published_at"`
}
ReleaseInfo describes a newer release available on GitHub.
func CheckForUpdate ¶
func CheckForUpdate(ctx context.Context, currentVersion string) (*ReleaseInfo, error)
CheckForUpdate queries GitHub Releases (with 24h cache) and returns a ReleaseInfo if a newer version exists. Returns nil if current or cached. The context allows cancellation if the parent command finishes first.