Documentation
¶
Overview ¶
Package upgrade implements `dust upgrade` — checks GitHub Releases for a newer version, downloads the matching platform tarball, verifies its SHA256 checksum, and atomically replaces the running binary.
Index ¶
- Constants
- func CurrentBinaryPath() (string, error)
- func CurrentPlatform() (string, string)
- func DownloadAndVerify(rel *Release) (tarballPath, tempDir string, err error)
- func ExtractBinary(tarballPath, tempDir string) (string, error)
- func IsManagedByGoInstall(binPath string) bool
- func IsNewer(current, latest string) bool
- func Replace(currentPath, newPath string) error
- type Release
Constants ¶
const DefaultRepo = "ariefsn/dust"
DefaultRepo is the GitHub repo dust ships from. Override via DUST_REPO env var if you fork it.
Variables ¶
This section is empty.
Functions ¶
func CurrentBinaryPath ¶
CurrentBinaryPath returns the absolute path of the currently running executable, resolving symlinks. Used to know what to overwrite.
func CurrentPlatform ¶
CurrentPlatform returns the GOOS/GOARCH for the running binary.
func DownloadAndVerify ¶
DownloadAndVerify fetches the release archive + checksums, verifies the SHA256, and returns the path to the verified tarball in a tempdir.
Caller must remove the returned tempdir when done.
func ExtractBinary ¶
ExtractBinary extracts the `dust` binary from `tarballPath` into `tempDir` and returns its path.
func IsManagedByGoInstall ¶
IsManagedByGoInstall reports whether the running binary appears to live under $GOPATH/bin or $GOBIN — the canonical `go install` locations. We refuse to self-update those because Go's tool chain expects to manage them.
Types ¶
type Release ¶
type Release struct {
Tag string
HTMLURL string
ArchiveURL string // tarball for current platform
ChecksumsURL string
}
Release describes a single GitHub release relevant to self-update.
func LatestRelease ¶
LatestRelease returns metadata for the latest release of the given repo. `repo` is the "owner/name" form (e.g. "ariefsn/dust"). `currentOS` / `currentArch` should be runtime.GOOS / runtime.GOARCH; passing them in keeps the function testable.
func (*Release) EnsureAssets ¶
EnsureAssets validates that the release carries the platform tarball and checksums file we need to install it. Caller invokes this only when an actual install is about to happen (skipping it for --check + dev-build flows that just want the tag string).