Documentation
¶
Index ¶
- func AssetName() string
- func CompareVersions(current, latest string) int
- func DownloadAsset(ctx context.Context, client *http.Client, url string, destDir string) (string, error)
- func DownloadChecksum(ctx context.Context, client *http.Client, checksumsURL string, ...) (string, error)
- func ExtractBinary(archivePath string, destDir string) (string, error)
- func NewHTTPClient() *http.Client
- func ReplaceBinary(targetPath string, newBinaryPath string) error
- func VerifySHA256(path string, expected string) error
- type AssetInfo
- type InstallMethod
- type ReleaseInfo
- func CheckLatestRelease(ctx context.Context, client *http.Client, repo string) (*ReleaseInfo, error)
- func FindRelease(ctx context.Context, client *http.Client, repo string, tag string) (*ReleaseInfo, error)
- func ListNewerReleases(ctx context.Context, client *http.Client, repo string, currentVersion string) ([]ReleaseInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssetName ¶
func AssetName() string
AssetName returns the expected archive filename for the current platform. Mirrors the GoReleaser name_template: lore_{{title .Os}}_{{arch}}.tar.gz
func CompareVersions ¶
CompareVersions compares two semver strings (with optional "v" prefix). Returns -1 if current < latest, 0 if equal, +1 if current > latest. Handles pre-release tags: v1.0.0-beta.1 < v1.0.0.
func DownloadAsset ¶
func DownloadAsset(ctx context.Context, client *http.Client, url string, destDir string) (string, error)
DownloadAsset downloads a release asset from url into destDir. Returns the path to the downloaded file.
func DownloadChecksum ¶
func DownloadChecksum(ctx context.Context, client *http.Client, checksumsURL string, archiveName string) (string, error)
DownloadChecksum downloads checksums.txt and extracts the SHA256 hash for the given archive filename.
func ExtractBinary ¶
ExtractBinary extracts the "lore" binary from a tar.gz or zip archive and returns the path to the extracted binary.
func NewHTTPClient ¶
NewHTTPClient returns an *http.Client configured for upgrade operations. It follows redirects (required for GitHub asset downloads) and has a generous timeout for large binary downloads.
func ReplaceBinary ¶
ReplaceBinary atomically replaces the binary at targetPath with newBinaryPath. Preserves the original file permissions.
func VerifySHA256 ¶
VerifySHA256 computes the SHA256 of the file at path and compares it to the expected hex-encoded hash.
Types ¶
type AssetInfo ¶
type AssetInfo struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
}
AssetInfo holds metadata for a release asset.
type InstallMethod ¶
type InstallMethod int
InstallMethod represents how lore was installed on the system.
const ( // InstallBinary means lore was installed as a standalone binary (self-update OK). InstallBinary InstallMethod = iota // InstallHomebrew means lore was installed via Homebrew. InstallHomebrew // InstallGoInstall means lore was installed via go install. InstallGoInstall )
func DetectInstallMethod ¶
func DetectInstallMethod(execPath string) (InstallMethod, string)
DetectInstallMethod inspects the resolved binary path to determine how lore was installed. Returns the method and, for non-binary methods, the command the user should run instead.
type ReleaseInfo ¶
type ReleaseInfo struct {
TagName string `json:"tag_name"`
Prerelease bool `json:"prerelease"`
Assets []AssetInfo `json:"assets"`
}
ReleaseInfo holds metadata for a GitHub release.
func CheckLatestRelease ¶
func CheckLatestRelease(ctx context.Context, client *http.Client, repo string) (*ReleaseInfo, error)
CheckLatestRelease fetches releases from the GitHub API and returns the newest one (including pre-releases). Uses /releases (not /releases/latest) because the latter excludes pre-releases.
func FindRelease ¶
func FindRelease(ctx context.Context, client *http.Client, repo string, tag string) (*ReleaseInfo, error)
FindRelease fetches releases and returns the one matching the given tag. Returns nil, nil if no matching release is found.
func ListNewerReleases ¶
func ListNewerReleases(ctx context.Context, client *http.Client, repo string, currentVersion string) ([]ReleaseInfo, error)
ListNewerReleases fetches recent releases and returns those newer than currentVersion, sorted newest first. Returns at most 20 entries.