update

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package update fetches the latest dac release tag from GitHub and caches it under ~/.dac/update-check.json so subsequent runs avoid the network round-trip. The result drives a one-line "update available" nudge printed at the end of a command.

Disable with DAC_NO_UPDATE_CHECK=1 or DO_NOT_TRACK=1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled(currentVersion string) bool

Enabled reports whether update checks should run for this build.

func Nudge

func Nudge(w io.Writer, res Result) bool

Nudge prints a one-line "update available" notice to w if res indicates a newer version. Returns true if it printed anything.

Skips when w is a non-terminal *os.File so scripts and CI logs stay clean.

Types

type Channel

type Channel string

Channel describes which release stream the current binary tracks.

const (
	ChannelStable Channel = "stable"
	ChannelEdge   Channel = "edge"
)

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker drives an asynchronous update check. Construct with NewChecker.

func NewChecker

func NewChecker(currentVersion string) *Checker

NewChecker returns a Checker configured for real-world use. Returns nil if the current version is not eligible for nudging (dev/test builds, opt-out).

func (*Checker) Start

func (c *Checker) Start(ctx context.Context) <-chan Result

Start kicks off the check in a goroutine and returns a channel that yields a single Result on success. The channel is closed without a value when the check is skipped, fails, or times out — receivers should use a select with a deadline so they never block the main flow.

type Result

type Result struct {
	LatestVersion  string
	CurrentVersion string
	Channel        Channel
	HasUpdate      bool
}

Result is what the asynchronous check returns.

Jump to

Keyboard shortcuts

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