Documentation
¶
Overview ¶
Package updatecheck looks for a newer gofer release (gofer-6x2n, docs/design/2026-10-13-update-check-design.md): the latest GitHub release by default, or a mirror's latest.yaml. Download (gofer-29gi) fetches and verifies a platform's binary for an upgrade; installing it is the caller's business.
Index ¶
- Constants
- func BinaryName(goos, goarch string) string
- func Newer(latest, current string) bool
- func ReleaseVersion(build string) string
- type Asset
- type Checker
- func (c *Checker) AssetFor(goos, goarch string) (Asset, error)
- func (c *Checker) AssetForVersion(ctx context.Context, goos, goarch, version string) (Asset, error)
- func (c *Checker) Check(ctx context.Context) Status
- func (c *Checker) Download(ctx context.Context, a Asset, dir string) (string, error)
- func (c *Checker) Run(ctx context.Context)
- func (c *Checker) SetOnAvailable(fn func(Status))
- func (c *Checker) Status() Status
- type Status
Constants ¶
const AppName = "gofer"
AppName is the {name} of the release artifacts.
Variables ¶
This section is empty.
Functions ¶
func BinaryName ¶ added in v0.154.0
BinaryName is the release binary of a platform: gofer-<os>-<arch>[.exe].
func Newer ¶
Newer reports whether latest is a newer release than current. Versions compare as X.Y.Z numbers; a development build of current ("0.152.3-2-gabc", "-dirty") counts as past its base release, so an equal base is not "newer". An unparsable version never reports newer.
func ReleaseVersion ¶ added in v0.194.0
ReleaseVersion turns a build version into the release version a download source names (gofer-n1vj): "0.152.3" for "0.152.3", "v0.152.3", "0.152.3-2-gabc1234" or "0.152.3 (abc1234)"; "" when the build is not a release version ("dev", a bare commit).
Types ¶
type Asset ¶ added in v0.154.0
type Asset struct {
OS string `json:"os"`
Arch string `json:"arch"`
Version string `json:"version"`
URL string `json:"url"`
// Name is the file the URL serves (a GitHub API URL does not end in it).
Name string `json:"name,omitempty"`
// SHA256 of the binary; "" = the source published none, so it is not verified.
SHA256 string `json:"sha256,omitempty"`
// contains filtered or unexported fields
}
Asset is one platform's binary of the latest checked release (gofer-29gi).
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker checks one source and keeps the latest result.
func New ¶
func New(current string, cfg func() config.UpdateConfig) *Checker
New builds a checker for the running version; cfg is read on every check, so a reload applies to the next one.
func (*Checker) AssetFor ¶ added in v0.154.0
AssetFor resolves a platform's binary from the last successful check: the GitHub release's archive, or the mirror's url_template.
func (*Checker) AssetForVersion ¶ added in v0.194.0
AssetForVersion resolves a platform's binary of ONE release (gofer-n1vj): "" or the latest checked release is what AssetFor returns; another version is resolved from the source itself — the mirror's url_template with that {version}, or that GitHub release's assets. Either way its checksum comes from that release's latest.yaml: a release whose checksum the source does not publish stays empty here and Download then refuses it (Q8: an unverified download is not allowed).
func (*Checker) Check ¶
Check runs one check now and returns (and keeps) its result. A failure is in Status.Error, never fatal.
func (*Checker) Download ¶ added in v0.154.0
Download fetches the asset into dir as BinaryName(os, arch), extracting it from an archive and verifying the published sha256. The result is executable.
func (*Checker) Run ¶
Run checks after firstCheckDelay and then every interval until ctx ends; a disabled config skips the periodic checks (and is re-read each time).
func (*Checker) SetOnAvailable ¶ added in v0.154.0
SetOnAvailable registers a callback run once per newly seen newer version (the update.available notification).
type Status ¶
type Status struct {
Current string `json:"current"`
Latest string `json:"latest,omitempty"`
Newer bool `json:"newer"`
Source string `json:"source"`
CheckedAt int64 `json:"checked_at"`
ReleasedAt string `json:"released_at,omitempty"`
ReleaseURL string `json:"release_url,omitempty"`
DownloadURL string `json:"download_url,omitempty"`
// SHA256 is the published checksum of this platform's binary ("" = the source
// published none: latest.yaml without files, or a release without latest.yaml).
SHA256 string `json:"sha256,omitempty"`
Description string `json:"description,omitempty"`
Error string `json:"error,omitempty"`
}
Status is the result of the latest check.