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

update

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package update implements a passive update-notification check that runs after the main diffsmith flow. It compares the running binary's version against the latest GitHub Release and prints a one-line suggestion if a newer release exists.

Design properties:

  • Silent on failure. Network errors, parse errors, missing cache directories — none of them surface to the user. A notification is a courtesy, not a load-bearing path.
  • Skips local builds. The "dev" and "*-dirty" version strings (stamped by Makefile's git-describe) bypass the check entirely so dev work isn't nagged about a release "upgrade" that's actually a downgrade.
  • Caches for 24h. We hit the GitHub Releases API at most once per day per user, even when the user runs diffsmith many times. The cache lives at $XDG_CACHE_HOME/diffsmith/latest-version.json (or $HOME/.cache/diffsmith/...).
  • Uses a swappable httpFetcher seam so tests don't hit the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, current string, w io.Writer)

Check prints a one-line update notification to w if a newer release exists on GitHub. Silent on every failure mode — never blocks, never returns errors. Safe to call from a cobra PersistentPostRun hook.

The cache hit path is O(1) read of a small JSON file; only the once-per-24h cache miss does network I/O, bounded by httpTimeout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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