update

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GitHubOwner is the GitHub owner for amux.
	GitHubOwner = "andyrewlee"
	// GitHubRepo is the GitHub repo for amux.
	GitHubRepo = "amux"
	// GitHubAPIBase is the base URL for GitHub API.
	GitHubAPIBase = "https://api.github.com"
)

Variables

This section is empty.

Functions

func CanWrite

func CanWrite(path string) bool

CanWrite checks if we have write permission to the binary path.

func ComputeChecksum

func ComputeChecksum(filepath string) (string, error)

ComputeChecksum computes the SHA256 checksum of a file.

func ExtractBinary

func ExtractBinary(archivePath, destDir string) (string, error)

ExtractBinary extracts the amux binary from a tar.gz archive. Returns the path to the extracted binary.

func GetCurrentBinaryPath

func GetCurrentBinaryPath() (string, error)

GetCurrentBinaryPath returns the path to the currently running binary.

func GetPlatformAssetName

func GetPlatformAssetName(version string) string

GetPlatformAssetName returns the expected asset name for the current platform.

func InstallBinary

func InstallBinary(newBinaryPath, currentBinaryPath string) error

InstallBinary performs an atomic replacement of the current binary. It stages the new binary in the same directory as the target to avoid cross-filesystem rename issues, then uses rename to atomically swap.

func IsDevBuild

func IsDevBuild(version string) bool

IsDevBuild returns true if this is a development build.

func IsGoInstall

func IsGoInstall() bool

IsGoInstall returns true if the binary appears to be installed via `go install`.

func IsHomebrewBuild added in v0.0.10

func IsHomebrewBuild() bool

IsHomebrewBuild returns true when the binary was built for Homebrew.

func VerifyChecksum

func VerifyChecksum(filepath, expectedChecksum string) error

VerifyChecksum verifies a file's SHA256 checksum.

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int64  `json:"size"`
	ContentType        string `json:"content_type"`
}

Asset represents a release asset.

func FindPlatformAsset

func FindPlatformAsset(release *Release) *Asset

FindPlatformAsset finds the appropriate asset for the current platform.

type CheckResult

type CheckResult struct {
	CurrentVersion  string
	LatestVersion   string
	UpdateAvailable bool
	ReleaseNotes    string
	Release         *Release
}

CheckResult contains the result of an update check.

type GitHubClient

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

GitHubClient handles GitHub API interactions.

func NewGitHubClient

func NewGitHubClient() *GitHubClient

NewGitHubClient creates a new GitHub client.

func (*GitHubClient) DownloadAsset

func (c *GitHubClient) DownloadAsset(url string, w io.Writer) error

DownloadAsset downloads an asset to the specified writer.

func (*GitHubClient) FetchChecksums

func (c *GitHubClient) FetchChecksums(release *Release) (map[string]string, error)

FetchChecksums downloads and returns the checksums.txt content.

func (*GitHubClient) FetchLatestRelease

func (c *GitHubClient) FetchLatestRelease() (*Release, error)

FetchLatestRelease fetches the latest release from GitHub.

type Release

type Release struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Body        string    `json:"body"`
	Draft       bool      `json:"draft"`
	Prerelease  bool      `json:"prerelease"`
	PublishedAt time.Time `json:"published_at"`
	Assets      []Asset   `json:"assets"`
}

Release represents a GitHub release.

type Updater

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

Updater orchestrates the check and upgrade workflow.

func NewUpdater

func NewUpdater(version, commit, date string) *Updater

NewUpdater creates a new Updater.

func (*Updater) Check

func (u *Updater) Check() (*CheckResult, error)

Check checks for available updates.

func (*Updater) Upgrade

func (u *Updater) Upgrade(release *Release) error

Upgrade downloads and installs the latest version.

func (*Updater) Version

func (u *Updater) Version() string

Version returns the current version.

type Version

type Version struct {
	Major      int
	Minor      int
	Patch      int
	Prerelease string
	Raw        string
}

Version represents a semantic version.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a semantic version string.

func (Version) Compare

func (v Version) Compare(other Version) int

Compare returns -1 if v < other, 0 if v == other, 1 if v > other.

func (Version) LessThan

func (v Version) LessThan(other Version) bool

LessThan returns true if v < other.

func (Version) String

func (v Version) String() string

String returns the version string with "v" prefix.

Jump to

Keyboard shortcuts

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