Documentation
¶
Overview ¶
Package version provides CLI version information and version checking utilities.
Index ¶
- Constants
- Variables
- func FormatUpdateMessage(currentVersion, latestVersion string) string
- func GetBuildDate() string
- func GetBuildType() string
- func GetCommit() string
- func GetUpdateInstructions() string
- func GetUpdateInstructionsForMethod(method InstallationMethod) string
- func GetVersion() string
- func IsDevBuild() bool
- func SelfUpdate(ctx context.Context) error
- type GitHubRelease
- type InstallationMethod
- type VersionInfo
Constants ¶
const ( // GitHubAPIURL is the GitHub Releases API endpoint GitHubAPIURL = "https://api.github.com/repos/specledger/specledger/releases/latest" // CheckTimeout is the timeout for version check requests CheckTimeout = 5 * time.Second )
Variables ¶
var ( // Version is the semantic version of the CLI Version = "dev" // Commit is the git commit hash Commit = "unknown" // Date is the build date Date = "unknown" // BuildType is the build type (development, production) BuildType = "development" )
Build-time variables set by GoReleaser via ldflags
Functions ¶
func FormatUpdateMessage ¶
FormatUpdateMessage formats a complete update message with all instructions.
func GetUpdateInstructions ¶
func GetUpdateInstructions() string
GetUpdateInstructions returns installation-method-specific update instructions.
func GetUpdateInstructionsForMethod ¶
func GetUpdateInstructionsForMethod(method InstallationMethod) string
GetUpdateInstructionsForMethod returns update instructions for a specific installation method.
func SelfUpdate ¶
SelfUpdate downloads and installs the latest version from GitHub Releases.
Types ¶
type GitHubRelease ¶
type GitHubRelease struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
HTMLURL string `json:"html_url"`
PublishedAt time.Time `json:"published_at"`
}
GitHubRelease represents the GitHub Releases API response
type InstallationMethod ¶
type InstallationMethod string
InstallationMethod represents how the CLI was installed
const ( MethodHomebrew InstallationMethod = "homebrew" MethodGoInstall InstallationMethod = "go-install" MethodBinary InstallationMethod = "binary" )
func DetectInstallationMethod ¶
func DetectInstallationMethod() InstallationMethod
DetectInstallationMethod attempts to determine how the CLI was installed.
type VersionInfo ¶
type VersionInfo struct {
CurrentVersion string `json:"current_version"` // Installed CLI version (e.g., "1.2.0")
LatestVersion string `json:"latest_version"` // Latest available version (e.g., "1.3.0")
LatestURL string `json:"latest_url"` // URL to release page
UpdateAvailable bool `json:"update_available"` // true if LatestVersion > CurrentVersion
CheckedAt time.Time `json:"checked_at"` // When the check was performed
Error string `json:"error,omitempty"` // Error message if check failed
}
VersionInfo represents version information from GitHub Releases API.
func CheckLatestVersion ¶
func CheckLatestVersion(ctx context.Context) *VersionInfo
CheckLatestVersion queries GitHub Releases API for the latest version. Returns VersionInfo with the latest version details, or an error message if check fails.