Documentation
¶
Overview ¶
Package release contains build metadata and best-effort release update checks.
Index ¶
Constants ¶
const ( // CheckInterval bounds both persistent-cache freshness and UI refreshes. // It deliberately keeps GitHub traffic low for short-lived TUI processes. CheckInterval = 6 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Checker ¶
type Checker struct {
Info Info
Client *http.Client
URL string // exported for deterministic tests; empty uses GitHub.
CachePath string
Now func() time.Time
// contains filtered or unexported fields
}
Checker checks GitHub's public releases API. It has no telemetry: the only network request is to api.github.com, and can be disabled by callers.
func NewChecker ¶
NewChecker creates a checker using ~/.config/moa/update.json (or MOA_CONFIG_DIR) as its shared persistent cache.
func (*Checker) Check ¶
Check returns a release result. Errors are intentionally returned to the caller so an interactive frontend can ignore them silently.
func (*Checker) LatestVersion ¶
LatestVersion returns the newest stable release, always asking GitHub. It bypasses both the cache interval and MOA_NO_UPDATE_CHECK because it serves an explicit user request (`moa update`) rather than the passive check.
type Info ¶
Info is build metadata injected by the release build. Development builds use the default "dev" version and deliberately never make update requests.
func (Info) DisplayVersion ¶
DisplayVersion returns the conventional v-prefixed version, or the raw build label when it is not a release version.
type Result ¶
type Result struct {
Current string `json:"current"`
Latest string `json:"latest,omitempty"`
UpdateAvailable bool `json:"update_available"`
}
Result is safe to display even when the check was unavailable.
type Semver ¶
Semver is a parsed semantic version. Build metadata is ignored for ordering.
func ParseSemver ¶
ParseSemver parses SemVer 2.0.0 versions with an optional v prefix.
type UpdateOptions ¶
type UpdateOptions struct {
Info Info // build metadata of the running binary
CheckOnly bool // report what would happen, download nothing
Out io.Writer // defaults to os.Stdout
Checker *Checker // defaults to NewChecker(Info)
Client *http.Client
BaseURL string // release download root, defaults to downloadBaseURL
ExecPath string // binary to replace, defaults to the running executable
GOOS string // defaults to runtime.GOOS
GOARCH string // defaults to runtime.GOARCH
}
UpdateOptions configures a self-update run. The zero value targets the running binary and the public GitHub releases; the remaining fields are seams that keep the flow testable without network or install access.