update

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForUpdates

func CheckForUpdates(currentVersion, repository string, verbose bool) (bool, string, error)

CheckForUpdates checks if there's a new version available. This is a thin wrapper around CheckForUpdatesContext that uses a default 5s timeout for backward compatibility with callers that don't manage their own context (e.g. `vers upgrade`).

func CheckForUpdatesContext added in v0.10.1

func CheckForUpdatesContext(ctx context.Context, currentVersion, repository string, verbose bool) (bool, string, error)

CheckForUpdatesContext checks if there's a new version available, honoring the supplied context's deadline/cancellation.

func IsDevVersion added in v0.10.1

func IsDevVersion(v string) bool

IsDevVersion reports whether a version string represents a local/dev build for which we should skip update checks entirely.

This catches:

  • the literal sentinels "dev" / "unknown" / "" set when ldflags weren't applied
  • "dev-<sha>" / "*-dirty" produced by our init() fallback against `git describe`
  • Go module *pseudo-versions* of the form "v0.0.0-<timestamp>-<commit>", which are what `go install` and `go run` produce against an untagged commit. Without this, integration test runs that build via the module graph end up with a perfectly valid-looking semver and try to "upgrade" to whatever real release is currently latest, contaminating test output.

func MaybeNotifyUpdate added in v0.10.1

func MaybeNotifyUpdate(ctx context.Context, current, repository string, timeout time.Duration, verbose bool)

MaybeNotifyUpdate prints an "update available" message to the given writer when a newer release is known. It is designed to be called once during CLI startup and is cheap on the hot path:

  • If a previously-cached LatestVersion is newer than `current`, the message prints synchronously with no network I/O.
  • Otherwise, if it's been longer than the configured check interval since the last successful check, it performs a single bounded HTTP request (capped at `timeout`) to refresh the cache. The cache (and NextCheck timestamp) are only advanced on a successful response, so transient network failures don't suppress the nag for an hour.

Errors are intentionally swallowed — the update check must never break a real command. When verbose is true, debug output is written to stderr.

func ShouldCheckForUpdate

func ShouldCheckForUpdate() bool

ShouldCheckForUpdate determines if it's time to check for updates

func UpdateCheckTime

func UpdateCheckTime()

UpdateCheckTime updates the next check time

Types

type GitHubRelease

type GitHubRelease struct {
	TagName    string `json:"tag_name"`
	Name       string `json:"name"`
	Body       string `json:"body"`
	Draft      bool   `json:"draft"`
	Prerelease bool   `json:"prerelease"`
	Assets     []struct {
		Name               string `json:"name"`
		BrowserDownloadURL string `json:"browser_download_url"`
		Size               int64  `json:"size"`
	} `json:"assets"`
	PublishedAt time.Time `json:"published_at"`
}

GitHubRelease represents a GitHub release

func GetLatestRelease

func GetLatestRelease(repository string, includePrerelease bool, verbose bool) (*GitHubRelease, error)

GetLatestRelease fetches the latest release from GitHub. If includePrerelease is true, it will return the latest release including prereleases. Uses a default 5s timeout.

func GetLatestReleaseContext added in v0.10.1

func GetLatestReleaseContext(ctx context.Context, repository string, includePrerelease bool, verbose bool) (*GitHubRelease, error)

GetLatestReleaseContext is like GetLatestRelease but honors the supplied context.

Jump to

Keyboard shortcuts

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