version

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VersionCheckURL is the URL to check for latest commit
	VersionCheckURL = "https://api.github.com/repos/base-go/cmd/commits/main"
)

Variables

View Source
var (
	// Version is the current version of Base CLI
	Version = "1.1.1"

	// CommitHash is the git commit hash at build time
	CommitHash = "unknown"

	// BuildDate is the date when the binary was built
	BuildDate = "unknown"

	// GoVersion is the version of Go used to build the binary
	GoVersion = "unknown"
)

Version information

Functions

func CheckForUpdates

func CheckForUpdates() (latestVersion, releaseURL, releaseNotes string, hasUpdate bool, err error)

CheckForUpdates checks GitHub for newer releases

func CheckForUpdatesCommit

func CheckForUpdatesCommit() (string, string, bool, error)

CheckForUpdates checks if there's a newer version available

func FormatUpdateMessage

func FormatUpdateMessage(current, latest, releaseURL, releaseNotes string) string

FormatUpdateMessage returns a formatted update message

func HasUpdate

func HasUpdate(current, latest string) bool

HasUpdate checks if the current version is behind the latest release

func PrintUpdateMessage

func PrintUpdateMessage()

PrintUpdateMessage prints update message if a new version is available

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

Asset represents a release asset

type BuildInfo

type BuildInfo struct {
	Version    string `json:"version"`
	CommitHash string `json:"commit_hash"`
	BuildDate  string `json:"build_date"`
	GoVersion  string `json:"go_version"`
}

BuildInfo contains all version information

func GetBuildInfo

func GetBuildInfo() BuildInfo

GetBuildInfo returns all version information

func (BuildInfo) String

func (bi BuildInfo) String() string

String returns a string representation of version information

type CommitInfo

type CommitInfo struct {
	SHA    string `json:"sha"`
	Commit struct {
		Message string `json:"message"`
		Author  struct {
			Date string `json:"date"`
		} `json:"author"`
	} `json:"commit"`
	HTMLURL string `json:"html_url"`
}

CommitInfo represents the GitHub commit response

type GithubRelease

type GithubRelease struct {
	TagName     string    `json:"tag_name"`
	PublishedAt time.Time `json:"published_at"`
	Body        string    `json:"body"`
	HTMLURL     string    `json:"html_url"`
}

GithubRelease represents a GitHub release

type Release

type Release struct {
	TagName     string    `json:"tag_name"`
	PublishedAt time.Time `json:"published_at"`
	Body        string    `json:"body"`
	HTMLURL     string    `json:"html_url"`
	Assets      []Asset   `json:"assets"`
}

Release represents a GitHub release

func CheckLatestVersion

func CheckLatestVersion() (*Release, error)

CheckLatestVersion checks GitHub for newer releases

Jump to

Keyboard shortcuts

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