Documentation
¶
Index ¶
- Constants
- func CanWrite(path string) bool
- func ComputeChecksum(filepath string) (string, error)
- func ExtractBinary(archivePath string, destDir string) (string, error)
- func GetCurrentBinaryPath() (string, error)
- func GetPlatformAssetName(version string) string
- func InstallBinary(newBinaryPath string, currentBinaryPath string) error
- func IsDevBuild(version string) bool
- func IsGoInstall() bool
- func VerifyChecksum(filepath string, expectedChecksum string) error
- type Asset
- type CheckResult
- type GitHubClient
- type Release
- type Updater
- type Version
Constants ¶
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 ComputeChecksum ¶
ComputeChecksum computes the SHA256 checksum of a file.
func ExtractBinary ¶
ExtractBinary extracts the amux binary from a tar.gz archive. Returns the path to the extracted binary.
func GetCurrentBinaryPath ¶
GetCurrentBinaryPath returns the path to the currently running binary.
func GetPlatformAssetName ¶
GetPlatformAssetName returns the expected asset name for the current platform.
func InstallBinary ¶
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 ¶
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 VerifyChecksum ¶
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 ¶
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 ¶
NewUpdater creates a new Updater.
func (*Updater) Check ¶
func (u *Updater) Check() (*CheckResult, error)
Check checks for available updates.