Help us shape the future of Go! Take the 2026 Go Developer Survey

updatecheck

package
v1.65.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package updatecheck notifies users about newer eng releases without a manual `eng version` check, npm-style: a short stderr notice after the command runs.

It is designed to never slow down or break a command invocation:

  • The notice is served from a local cache file under the OS cache dir, so the common path performs one small file read and no network I/O.
  • Refreshing the cache happens in a fire-and-forget goroutine with a short timeout; failures are swallowed silently.
  • The check is skipped for dev builds, when ENG_NO_UPDATE_CHECK is set, for the `version` command itself (it does its own check), and in tests (via ui.DisableProgress, mirroring runlog).

Index

Constants

View Source
const (

	// CheckInterval is how often the cached latest-release tag is refreshed.
	CheckInterval = 24 * time.Hour
)

Variables

This section is empty.

Functions

func CacheFile

func CacheFile() (string, error)

CacheFile returns the cache path, creating the parent dir when possible. ENG_UPDATE_CHECK_FILE overrides the default (OS cache dir), keeping tests hermetic.

func Disabled

func Disabled() bool

Disabled reports whether the automatic check is turned off.

func NotifyIfAvailable

func NotifyIfAvailable(cmdName string)

NotifyIfAvailable prints a short npm-style update notice to stderr when the cached latest tag is newer than the running version. It performs no network I/O. Pass the invoked (sub)command name so self-checking and machine-consumed commands stay quiet.

func RefreshAsync

func RefreshAsync()

RefreshAsync refreshes the cached latest-release tag in the background when the cache is missing or older than CheckInterval. It returns immediately and never reports errors; the next invocation serves the refreshed value.

func ShouldSkip

func ShouldSkip(cmdName string) bool

ShouldSkip reports whether the notice/refresh should be skipped for the invoked command name (e.g. "version", "completion", "__complete").

Types

This section is empty.

Jump to

Keyboard shortcuts

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