update

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package update checks GitHub for newer clawker releases and caches results.

Foundation-tier package: stdlib + net/http + yaml.v3, no internal imports. The caller passes the current version string (no dependency on internal/build).

Designed for background use — the caller launches CheckForUpdate in a goroutine with a cancellable context. Context cancellation cleanly aborts the HTTP request when the CLI command finishes before the check completes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldCheckForUpdate

func ShouldCheckForUpdate(stateFilePath, currentVersion string) bool

ShouldCheckForUpdate returns false if update checks should be suppressed. Suppression conditions:

  • CLAWKER_NO_UPDATE_NOTIFIER env var is set (non-empty)
  • CI env var is set (non-empty) — standard CI detection
  • currentVersion is "DEV" — development build
  • stateFilePath is non-empty and cache is fresh (checked < 24h ago)

Types

type CheckResult

type CheckResult struct {
	CurrentVersion string
	LatestVersion  string
	ReleaseURL     string
}

CheckResult is returned when a newer version is available.

func CheckForUpdate

func CheckForUpdate(ctx context.Context, stateFilePath, currentVersion, repo string) (*CheckResult, error)

CheckForUpdate checks the GitHub API for a newer release of the given repo. Returns (nil, nil) if the current version is latest or checks are suppressed. Returns (nil, error) on API/network failures. Returns (*CheckResult, nil) when a newer version is available.

The context controls the HTTP request lifetime — cancel it to abort cleanly. repo should be "owner/name", e.g. "schmitthub/clawker".

type StateEntry

type StateEntry struct {
	CheckedAt      time.Time `yaml:"checked_at"`
	LatestVersion  string    `yaml:"latest_version"`
	LatestURL      string    `yaml:"latest_url"`
	CurrentVersion string    `yaml:"current_version"`
}

StateEntry is the cached update check result, persisted as YAML.

Jump to

Keyboard shortcuts

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