updatecheck

package
v0.181.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const AppName = "gofer"

AppName is the {name} of the release artifacts.

Variables

This section is empty.

Functions

func BinaryName added in v0.154.0

func BinaryName(goos, goarch string) string

BinaryName is the release binary of a platform: gofer-<os>-<arch>[.exe].

func Newer

func Newer(latest, current string) bool

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.

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

func (c *Checker) AssetFor(goos, goarch string) (Asset, error)

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

func (c *Checker) Check(ctx context.Context) Status

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

func (c *Checker) Download(ctx context.Context, a Asset, dir string) (string, error)

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

func (c *Checker) Run(ctx context.Context)

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

func (c *Checker) SetOnAvailable(fn func(Status))

SetOnAvailable registers a callback run once per newly seen newer version (the update.available notification).

func (*Checker) Status

func (c *Checker) Status() Status

Status returns the latest result (CheckedAt 0 = never checked).

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL