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

upgrade

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package upgrade implements `codegraph upgrade` (CLI-02, D-11..D-14): resolve the target release version from GitHub Releases, download and verify its sigstore-go signature bundle IN-PROCESS (D-12 — never shell out to a cosign CLI), and only on successful verification atomically replace the running binary (D-13). This is the only intentional network path in the whole binary (D-15/telemetry) and the project's first cryptographic-verification code (T-06-06-01/T-06-06-02).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(currentVersion, targetPath string, opts Options) error

Run executes `codegraph upgrade` end to end: detect a Homebrew-managed install BEFORE resolving anything (D-11) — under --check it prints the pointer and returns nil (exit 0, D-09/D-10: a question, answered), otherwise it refuses with the same pointer and a non-nil error (exit non-zero, D-05: a mutation, declined) — → resolve latest → (Check? report and return, no download) → refuse a non-writable targetPath BEFORE downloading (D-13) → download → verify (a non-nil error is FATAL and Run NEVER falls through to swap — Pitfall 7, T-06-06-01/02) → swap. targetPath is the self-replace target; the caller (internal/cli/ upgrade.go) resolves it via os.Executable() so Run itself stays fully testable without touching the real running binary.

Types

type Options

type Options struct {
	// Check, when true, resolves and reports the latest version WITHOUT
	// downloading, verifying, or swapping anything (D-11).
	Check bool

	// Version pins a specific release tag to install; empty means "the
	// resolved latest."
	Version string

	// Force, when true, bypasses the same-version no-op guard and forces a
	// full download → verify → swap reinstall even when the resolved
	// target already matches currentVersion. It does NOT affect
	// verification in any way — verify() remains an unconditional,
	// fail-closed step before every swap regardless of Force
	// (T-08-03-01).
	Force bool

	// Out receives human-readable status lines (the --check report, the
	// final "upgraded to vX" line). Defaults to io.Discard if nil.
	Out io.Writer
	// contains filtered or unexported fields
}

Options configures a single upgrade.Run invocation (D-11). The four unexported func fields are the injectable seams described above — zero value (nil) means "use the real implementation."

Jump to

Keyboard shortcuts

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