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
- type Asset
- type Checker
- func (c *Checker) AssetFor(goos, goarch 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].
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) 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.