update

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ModeOn     = "on"     // stage and apply updates automatically
	ModeNotify = "notify" // only print a notice when a release is available
	ModeOff    = "off"    // no checks at all
)

Auto-update modes; config.Settings.AutoUpdateMode resolves to one of these.

View Source
const ReleasesPage = "https://github.com/arc53/DocsGPT-cli/releases"

ReleasesPage lists every release with its notes.

Variables

This section is empty.

Functions

func Apply

func Apply(rel *Release, targetPath, currentVersion string) error

Apply downloads, verifies, and installs rel's binary at targetPath, keeping the replaced binary (running as currentVersion) as the rollback backup. On failure the old binary is left in place.

func ApplyStaged

func ApplyStaged(current, targetPath string) (string, error)

ApplyStaged swaps a valid staged binary into targetPath and returns the new version, or "" when nothing applied. The manifest is re-verified against the staged file so a corrupt or foreign binary is never installed; any invalid staging area is discarded.

func AssetName

func AssetName() string

AssetName returns the release archive filename for the current platform, matching the name_template in .goreleaser.yaml.

func CachedNotice

func CachedNotice(current string) string

CachedNotice returns the newer release recorded by a previous background check, or "". Reads only local state, never the network.

func CheckAndApply

func CheckAndApply(currentVersion string) (string, error)

CheckAndApply is the host daemon's update pass: check for a release, download, verify, and swap the running binary in place. Returns the installed version, or "" when already current. The caller restarts into the new binary.

func ClearStaging

func ClearStaging()

ClearStaging removes any staged update.

func ExecutablePath added in v1.7.0

func ExecutablePath() (string, error)

ExecutablePath is the symlink-resolved path of the running binary, the file an update replaces.

func IsHomebrewPath

func IsHomebrewPath(path string) bool

IsHomebrewPath reports whether a resolved executable path is managed by Homebrew and must be updated via brew instead. Cellar covers formulae and Caskroom covers casks; on Apple Silicon both sit under /opt/homebrew, but on an Intel Mac the prefix is /usr/local, so the Caskroom check is what catches a cask install there.

func IsNewer

func IsNewer(latest, current string) bool

IsNewer reports whether latest is a higher version worth updating to.

Anything that is not a plain release is refused, even though semver orders v1.6.0-rc1 above v1.5.1: installing one stamps the binary with a version IsReleaseVersion rejects, so that install would stop checking for updates altogether. release.prerelease in .goreleaser.yaml already keeps an -rc out of releases/latest; this is the second lock on the same door.

func IsReleaseVersion

func IsReleaseVersion(version string) bool

IsReleaseVersion reports whether version comes from an exact release tag, as opposed to "dev" or a between-tags/dirty git describe string.

func MarkUpdated added in v1.7.0

func MarkUpdated(version string)

MarkUpdated records that version was installed, so the next chat shows what is new in it.

func RecordCheck

func RecordCheck(rel *Release)

RecordCheck persists the result of a release lookup so later runs can skip re-querying GitHub for a day.

func Restart

func Restart(exePath string) error

Restart replaces the current process with the binary at exePath, keeping PID, args, and environment — service supervisors never see an exit, so their restart policy doesn't matter.

func Rollback

func Rollback(currentVersion, targetPath string) (string, error)

Rollback swaps the current binary with the backup kept by the last update and marks the replaced version as skipped so auto-update won't reinstall it. Returns the version rolled back to ("" when the backup predates manifests).

func RunWorker

func RunWorker(current string)

RunWorker is the worker process body: refresh the release cache and, in auto-update mode, stage the new binary. Never prints; state files are the only output.

func SetSkipVersion

func SetSkipVersion(version string)

SetSkipVersion records the version auto-update must not install; "" clears the skip.

func ShouldSpawnWorker

func ShouldSpawnWorker(current, mode string) bool

ShouldSpawnWorker reports whether a background pass would do useful work: the daily check is due, or a known newer release still needs staging.

func ShownNotes added in v1.7.0

func ShownNotes()

ShownNotes records that the pending notes were shown.

func SkipVersion

func SkipVersion() string

SkipVersion returns the version auto-update must not install (set by a rollback), or "".

func SpawnWorker

func SpawnWorker()

SpawnWorker relaunches this executable as a detached background process. Fire-and-forget: failures are silent, the next launch tries again.

func Stage

func Stage(rel *Release) error

Stage downloads and verifies the release binary for this platform and parks it in the staging area for a later ApplyStaged.

func StagedVersion

func StagedVersion() string

StagedVersion returns the version waiting in the staging area, or "".

func TidyNotes added in v1.7.0

func TidyNotes(body string) string

TidyNotes readies release notes for the terminal: GoReleaser's "## Changelog" heading, merge commits and commit hashes go.

Types

type Asset

type Asset struct {
	Name        string `json:"name"`
	DownloadURL string `json:"browser_download_url"`
}

type Notes added in v1.7.0

type Notes struct {
	Version string `json:"version"`
	Body    string `json:"body"` // markdown, as GitHub has it
	URL     string `json:"url,omitempty"`
}

Notes are a release's notes.

func LatestNotes added in v1.7.0

func LatestNotes(ctx context.Context) (Notes, error)

LatestNotes returns the latest release's notes: those of the last check when it was within a day, else fetched from GitHub (and recorded), else, offline, those of the last check however old.

func PendingNotes added in v1.7.0

func PendingNotes(current string) (Notes, bool)

PendingNotes returns the notes of the update that installed current, when they are known and have not been shown yet (see ShownNotes).

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	HTMLURL string  `json:"html_url"`
	Body    string  `json:"body"` // the release notes, markdown
	Assets  []Asset `json:"assets"`
}

func FetchLatest

func FetchLatest(timeout time.Duration) (*Release, error)

FetchLatest queries GitHub for the most recent release.

func FetchLatestContext added in v1.7.0

func FetchLatestContext(ctx context.Context) (*Release, error)

FetchLatestContext is FetchLatest, for as long as ctx lasts.

Jump to

Keyboard shortcuts

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