Documentation
¶
Index ¶
- Constants
- Variables
- func AssetName(tag, goos, goarch string) (string, error)
- func AssetNameFor(binaryName, tag, goos, goarch string) (string, error)
- func CanonicalPath(path string) string
- func CompareVersions(current, latest string) (int, bool)
- func DefaultCacheDir() (string, error)
- func DefaultCachePath() (string, error)
- func DownloadReleaseAsset(ctx context.Context, client *http.Client, tag, assetName, destPath string) error
- func ExecutablePath() (string, string, error)
- func ExtractBinaryFromTarGz(archivePath, destDir string) (string, error)
- func ExtractBinaryFromTarGzNamed(binaryName, archivePath, destDir string) (string, error)
- func ExtractBinaryFromZip(archivePath, destDir string) (string, error)
- func ExtractBinaryFromZipNamed(binaryName, archivePath, destDir string) (string, error)
- func FetchChecksums(ctx context.Context, client *http.Client, tag string) (map[string]string, error)
- func FetchLatestTag(ctx context.Context, client *http.Client) (string, error)
- func IsNoUpdateCheckEnv() bool
- func IsScoopShapedPath(path string) bool
- func IsUnpublishedTestVersion(version string) bool
- func IsUpdateAvailable(current, latest string) bool
- func NormalizeVersion(version string) string
- func ParseChecksums(data []byte) (map[string]string, error)
- func ReplaceBinary(srcPath, destPath string) (bool, error)
- func SaveCache(path string, cache *Cache) error
- func ScoopAppsDir() string
- func VerifySHA256(path, expected string) error
- type Cache
- type InstallKind
- type Notifier
- type ScoopInstallRoot
- type ScoopScope
Constants ¶
const ( RepoOwner = "avivsinai" RepoName = "agent-message-queue" RepoSlug = RepoOwner + "/" + RepoName ModulePath = "github.com/avivsinai/agent-message-queue" BinaryName = "amq" ChecksumsFilename = "checksums.txt" DefaultCheckInterval = 24 * time.Hour EnvNoUpdateCheck = "AMQ_NO_UPDATE_CHECK" // EnvCacheDir overrides the update-check cache directory. It takes // precedence over os.UserCacheDir so tests (and operators) can redirect // the cache on platforms where UserCacheDir ignores HOME (darwin's // ~/Library/Caches). When unset, production behavior is unchanged. EnvCacheDir = "AMQ_CACHE_DIR" )
Variables ¶
var ( ErrUnsupportedOS = errors.New("unsupported operating system") ErrUnsupportedArch = errors.New("unsupported architecture") )
var CompanionBinaries = []string{"amq-keepalive", "amq-bridge", "amq-acp"}
CompanionBinaries are the amq-adjacent binaries published from the same release but not packaged by the Homebrew formula or Scoop manifest: only amq itself goes through a package manager. They are direct-installed at a stable path (~/.local/bin or next to amq) and upgraded in place.
Functions ¶
func AssetNameFor ¶ added in v0.74.0
AssetNameFor returns the release archive asset name for a given binary (amq, amq-keepalive, amq-bridge, amq-acp). The archive name template is <binary>_<version>_<os>_<arch>.<ext>, matching .goreleaser.yaml's name_template per build. amq and amq-keepalive publish Windows zip assets; the other companions are darwin/linux tar.gz. This function does not enforce that matrix — the caller picks an asset the release publishes.
func CanonicalPath ¶ added in v0.74.0
CanonicalPath resolves the existing portion of path and preserves any non-existent suffix below it.
func CompareVersions ¶
func DefaultCacheDir ¶ added in v0.74.0
DefaultCacheDir returns the platform user-cache directory. It is shared by update files and keepalive readiness files so platform cache discovery stays in one package.
func DefaultCachePath ¶
func DownloadReleaseAsset ¶
func ExecutablePath ¶
func ExtractBinaryFromTarGz ¶
func ExtractBinaryFromTarGzNamed ¶ added in v0.74.0
ExtractBinaryFromTarGzNamed extracts the named binary (without any .exe suffix) from a tar.gz release archive into destDir and returns its path. It accepts both the bare name and the name with a .exe suffix so a single reader handles Windows archives carried in a tar.gz.
func ExtractBinaryFromZip ¶
func ExtractBinaryFromZipNamed ¶ added in v0.74.0
ExtractBinaryFromZipNamed extracts the named binary (without any .exe suffix) from a zip release archive into destDir and returns its path.
func FetchChecksums ¶
func IsNoUpdateCheckEnv ¶
func IsNoUpdateCheckEnv() bool
func IsScoopShapedPath ¶ added in v0.74.0
IsScoopShapedPath reports whether path contains the conventional Scoop root/apps layout on Windows.
func IsUnpublishedTestVersion ¶ added in v0.74.0
IsUnpublishedTestVersion reports whether version is a documented test sentinel (9.9.9 or 0.0.0-test) rather than a publishable latest.
func IsUpdateAvailable ¶
func NormalizeVersion ¶
func ReplaceBinary ¶
func ScoopAppsDir ¶ added in v0.74.0
func ScoopAppsDir() string
ScoopAppsDir returns the user-scope Scoop apps directory on Windows. It is empty on other operating systems and remains for callers that need only the historical single-root view.
func VerifySHA256 ¶
Types ¶
type Cache ¶
type InstallKind ¶ added in v0.74.0
type InstallKind int
InstallKind classifies how a resolved executable path was installed.
const ( // InstallDirect is a manually-placed binary (~/.local/bin, a versions // dir, etc.); amq upgrade owns the download+checksum+atomic-replace path. InstallDirect InstallKind = iota // InstallHomebrew means the resolved path lives under a Homebrew Cellar // or prefix bin dir; amq upgrade delegates to brew so it does not corrupt // brew bookkeeping. Companions are never Homebrew-owned. InstallHomebrew // InstallScoop means the resolved path lives under the Scoop apps dir on // Windows user scope; amq upgrade delegates to scoop. Companions are never // Scoop-owned. InstallScoop // InstallScoopGlobal means the resolved path lives under Scoop's global apps // dir on Windows; the delegate must include Scoop's global flag. InstallScoopGlobal // InstallScoopUnknown means the path looks like a Scoop apps path but is not // under a configured user or global Scoop root. It must never self-replace. InstallScoopUnknown )
func ClassifyInstall ¶ added in v0.74.0
func ClassifyInstall(resolvedPath, homebrewPrefix string) InstallKind
ClassifyInstall determines how a binary was installed using one Homebrew prefix. It remains as a compatibility wrapper; callers that have more than one candidate prefix should use ClassifyInstallAgainstPrefixes.
func ClassifyInstallAgainstPrefixes ¶ added in v0.74.0
func ClassifyInstallAgainstPrefixes(resolvedPath string, homebrewPrefixes []string) InstallKind
ClassifyInstallAgainstPrefixes classifies a binary against every known Homebrew prefix. A path in <prefix>/Cellar is package-managed. A path in <prefix>/bin is package-managed only when the object is a symlink that resolves into that same prefix's Cellar; a regular file there remains an ambiguous direct install for the CLI's final safety guard.
func (InstallKind) IsPackageManaged ¶ added in v0.74.0
func (k InstallKind) IsPackageManaged() bool
IsPackageManaged reports whether the kind delegates to an external package manager rather than self-replacing.
func (InstallKind) IsScoop ¶ added in v0.74.0
func (k InstallKind) IsScoop() bool
IsScoop reports whether the kind came from a Scoop-shaped installation.
func (InstallKind) IsScoopGlobal ¶ added in v0.74.0
func (k InstallKind) IsScoopGlobal() bool
IsScoopGlobal reports whether the kind is a known global Scoop install.
type Notifier ¶
type Notifier struct {
CurrentVersion string
NoCheck bool
Stderr io.Writer
Now func() time.Time
Client *http.Client
CachePath string
CheckInterval time.Duration
// FetchLatest overrides FetchLatestTag. Tests inject it so a sentinel
// GitHub payload can be exercised without a network round trip.
FetchLatest func(context.Context, *http.Client) (string, error)
}
type ScoopInstallRoot ¶ added in v0.74.0
type ScoopInstallRoot struct {
Path string
Scope ScoopScope
}
ScoopInstallRoot describes one Scoop apps directory and its installation scope. Paths are absolute where the platform can make them absolute.
func ScoopInstallRoots ¶ added in v0.74.0
func ScoopInstallRoots() []ScoopInstallRoot
ScoopInstallRoots returns the configured user and global Scoop apps directories on Windows. Scoop honors $SCOOP and $SCOOP_GLOBAL; the default roots are ~/scoop and C:\ProgramData\scoop.
type ScoopScope ¶ added in v0.74.0
type ScoopScope string
ScoopScope identifies the Scoop installation scope for a configured root.
const ( ScoopScopeUser ScoopScope = "user" ScoopScopeGlobal ScoopScope = "global" )