version

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	GitHubRepoOwner    = "sunerpy"
	GitHubRepoName     = "pt-tools"
	GitHubReleasesURL  = "https://api.github.com/repos/" + GitHubRepoOwner + "/" + GitHubRepoName + "/releases"
	GitHubChangelogURL = "https://github.com/" + GitHubRepoOwner + "/" + GitHubRepoName + "/blob/main/CHANGELOG.md"
	MaxDisplayReleases = 3
	CheckInterval      = 24 * time.Hour
	RequestTimeout     = 15 * time.Second
)

Variables

View Source
var (
	Version   = "unknown" // 默认值,编译时通过 ldflags 覆盖
	BuildTime = "unknown" // 默认值,编译时通过 ldflags 覆盖
	CommitID  = "unknown" // 默认值,编译时通过 ldflags 覆盖
)

Functions

func CompareVersions added in v0.4.0

func CompareVersions(a, b *SemVer) int

Types

type CheckOptions added in v0.4.0

type CheckOptions struct {
	Force    bool
	ProxyURL string
}

type Checker added in v0.4.0

type Checker struct {
	// contains filtered or unexported fields
}

func GetChecker added in v0.4.0

func GetChecker() *Checker

func NewChecker added in v0.4.0

func NewChecker() *Checker

func (*Checker) CheckForUpdates added in v0.4.0

func (c *Checker) CheckForUpdates(ctx context.Context, opts CheckOptions) (*VersionCheckResult, error)

func (*Checker) GetCachedResult added in v0.4.0

func (c *Checker) GetCachedResult() *VersionCheckResult

func (*Checker) ShouldCheck added in v0.4.0

func (c *Checker) ShouldCheck() bool

type GitHubRelease added in v0.4.0

type GitHubRelease struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Body        string    `json:"body"`
	HTMLURL     string    `json:"html_url"`
	PublishedAt time.Time `json:"published_at"`
	Prerelease  bool      `json:"prerelease"`
	Draft       bool      `json:"draft"`
}

type ReleaseInfo added in v0.4.0

type ReleaseInfo struct {
	Version     string `json:"version"`
	Name        string `json:"name"`
	Changelog   string `json:"changelog"`
	URL         string `json:"url"`
	PublishedAt int64  `json:"published_at"`
}

type SemVer added in v0.4.0

type SemVer struct {
	Major      int
	Minor      int
	Patch      int
	Prerelease string
	Build      string
}

func ParseVersion added in v0.4.0

func ParseVersion(version string) *SemVer

type VersionCheckResult added in v0.4.0

type VersionCheckResult struct {
	CurrentVersion  string        `json:"current_version"`
	HasUpdate       bool          `json:"has_update"`
	NewReleases     []ReleaseInfo `json:"new_releases,omitempty"`
	ChangelogURL    string        `json:"changelog_url,omitempty"`
	HasMoreReleases bool          `json:"has_more_releases,omitempty"`
	CheckedAt       int64         `json:"checked_at"`
	Error           string        `json:"error,omitempty"`
}

type VersionInfo added in v0.4.0

type VersionInfo struct {
	Version   string `json:"version"`
	BuildTime string `json:"build_time"`
	CommitID  string `json:"commit_id"`
}

func GetVersionInfo added in v0.4.0

func GetVersionInfo() VersionInfo

Jump to

Keyboard shortcuts

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